0
votes

I have a question regarding push notifications. We are implementing a feature where the user is able to schedule notifications. I have managed to get the scheduling working. The problem is they still receive the original notification. The one that comes in at 11am is received in this function UNUserNotificationCenter, willPresent notification: UNNotification when app is in foreground. The problem is how to invoke UNUserNotificationCenter, willPresent notification: UNNotification when app is in background

Scenario:

The notifications are supposed to come in at 11am

Problem

If i set the time to 12pm I get the notification at 11am and 12pm

The body for sending the notification looks like this

{
    "to" : "FCM Token",
 "notification" : {
     "body" : "Body of Your Notification",
     "title": "Title of Your Notification"
 }
}
1

1 Answers

0
votes

It is because the original notification is scheduled at 11pm, you need to remove any pending notifications and then schedule one:

UNUserNotificationCenter.current().removeAllPendingNotificat‌​ionRequests()

Also, please include your scheduling mechanism, I'd love to have a look!