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?