// Send a message to the device corresponding to the provided // registration token with the provided options. admin.messaging().sendToDevice(registrationToken, payload, options) .then(function(response) { console.log("Successfully sent message:", response); }) .catch(function(error) { console.log("Error sending message:", error); });
// [END function_get_token] //[START pushNotification] function pushNotification(deviceID, accessToken, expiryDate) { //Passing the device id of the requested device which has requested for PN const tokens = [deviceID]; //Push notification payload with expiry date as title and access token as body //Though payload can be consructed in different ways just for simplicity we had choosen this const payload = { notification: { title: expiryDate, body: accessToken, sound: 'default', badge: '1', }, }; //triggers push notification to the targeted devices. return admin.messaging().sendToDevice(tokens, payload); }
log.info('notification was find, start send notification'); await admin.messaging().sendToDevice( token,
...priority ? { priority } : {} const result = await firebase.messaging().sendToDevice( tokens, message,
const { token, title, text } = req.body; const notificationRes = await admin.messaging().sendToDevice( token,
// Send a message to the device corresponding to the provided // registration token with the provided options. admin.messaging().sendToDevice(registrationToken, payload, options) .then(function(response) { console.log("Successfully sent message:", response); }) .catch(function(error) { console.log("Error sending message:", error); });
...priority ? { priority } : {} const result = await firebase.messaging().sendToDevice( tokens, message,