Saturday, October 13, 2018

Does iOS throttle scheduled local push notifications?

Leave a Comment

My app receives silent push notifications via FCM, as I see in the logging the are received and handled. What my app then does is decide to some logic if a notification is shown to the user or not. This sometimes works, sometimes doesn't. It seems to me as if it works first and then suddenly stops working, so I'm guessing if it may be a throttling problem?

I do schedule 5 notifications 30 seconds apart - so the user does not miss the notification:

    for i in 0...5 {         let notification = UNMutableNotificationContent()         notification.title = NSLocalizedString("bed_wet", comment: "")         notification.subtitle = device.lookAfterPatientString         notification.sound = UNNotificationSound(named: "alarm.mp3")         notification.categoryIdentifier = Notification.Category.alarm         notification.userInfo = ["identifier": device.id]          let timeInterval = max(1, delaySeconds) + i * 30         let notificationTrigger = UNTimeIntervalNotificationTrigger(timeInterval: TimeInterval(timeInterval), repeats: false)         let request = UNNotificationRequest(identifier: UUID.init().uuidString, content: notification, trigger: notificationTrigger)          UNUserNotificationCenter.current().add(request) { error in             ...         }     } 

can this loop be the problem?

1 Answers

Answers 1

Try it with dispatch_async, Several code that not blocking main thread maybe called and some times not called.

The second problem is maybe iOS have logic that prevent an app to spam the phone. Have u seen instagram notification limited from maybe hundred to only several notification.

Thanks

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment