I am trying to send a notification via a Cloud Function (using the built-in Firebase Messenger notifications). This is how to send the notification:
// Prepare and send a notification to each token
const responses = await Promise.all(tokens.map(token => {
const message = {
notification: {
title: title,
body: body,
},
apns: {
payload: {
aps: {
sound: "default",
},
},
},
token: token,
};
return admin.messaging().send(message);
}));
The code above will send a notification to all the given tokens.
However, the issue occurs when you want to lead the user to a specific page. Notifications aren't so useful when they don't lead to the right page so this is quite important.