Reputation: 3278
I want to run some code every time a local notification is fired. What's the best and proper way to do this? I don't think it's possible to run something in the background without the app being opened. Is there something like a count property that counts how many notification has been fired since the app has closed or do I have to implement that myself? Would that even be the best way to do it?
Upvotes: 1
Views: 331
Reputation: 2346
If you want to have notifications displayd by a background trigger you need to use push/remote notififications.
As for counting the number of notifications, that is exactly what UIApplication.sharedApplication.applicationIconBadgeNumber
is for. Then when the app opens you can check the property to see how many badges are set, and also reset them if you want (just set the value to 0).
Upvotes: 2