Skip to content

Instantly share code, notes, and snippets.

@milankamilya
Created October 23, 2019 16:52
Show Gist options
  • Save milankamilya/985f795c8d29d442a1f79143d3703a51 to your computer and use it in GitHub Desktop.
Save milankamilya/985f795c8d29d442a1f79143d3703a51 to your computer and use it in GitHub Desktop.
function removePushNotification(body, prevNotificationID){
var notification = new apn.Notification();
notification.expiry = Math.floor(Date.now() / 1000) + 60; // Expires 1 min from now.
notification.badge = 1; //you can update the count as it required
notification.alert = body.alertMessage;
// for Silent Notification
notification.sound = "";
notification.contentAvailable = true;
notification.payload = {'messageFrom': 'John Appleseed'};
notification.topic = "<application bundle identifier>";
notification.id = prevNotificationID;
apnProvider.send(notification, body.deviceToken).then( (result) => {
console.log('APNS Response : \n', result);
res.send('POST App Push Notification');
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment