Mikrasya Mikrasya - 1 month ago 36
Swift Question

iOS 10 Local Notifications not working (migrating to UserNotifications framework)

I have an app that had local notifications working fine in iOS 9.
I am updating the app to iOS 10.

After upgrading to Swift 3, I have migrated the local notifications to new UserNotifications framework (I will only support iOS 10 so it is fine).
However, I don't get any notifications in this app. Same code in a vanilla app works.

I've requested authorization for notifications and that part is working fine.
I've also tried adding UserNotification.framework but that does not make any difference.

What can be the reason for not seeing notifications after migrating?

Answer

Somehow the issues is resolved. I've tried multiple things so I don't know what was the solution :(. On the other hand, I was doing one mistake which made debugging very difficult for me. Looks like the identifier in UNNotificationRequest should be unique. I used to schedule multiple notifications and set the same identifier to all of them. This caused all previous notifications to be overwritten by the very last one scheduled.

Comments