Is there a way to clear the remote notification from the notification banner when swiping down from the top of the iPhone screen. I tried setting the badge number to zero:
This for scenario when the app is forcefully terminated by the user :
First of all send nonzero badge when you want to send Birthday reminders notifications to the users via push notifications , For example :
{
"aps": {
"alert": {
"title": "Hey! Urgent Reminder",
"body": "Do not forget my wife SURPRISE BIRTHDAY PARTY"
},
"badge": 1
}
}
After that , When there is no need of showing notifications in the device , you can send silent notification with zero badge that will clear badge and notifications even if app is forcefully terminated by the user but didReceiveRemoteNotification
will not called because app is terminated.
payload for silent push notification :
{
"aps" : {
"content-available" : 1,
"badge" : 0,
"Priority" : 10
}
}
After send that payload will automatically clear badge and delete push notification from Notification Center.
Not. If badge was zero before sending silent notification , will not clear notifications.
https://developer.apple.com/library/archive/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CreatingtheNotificationPayload.html