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?
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.