Manage alerts of multiple local notifications fired in a single way?
I need your help :(
Scenario: (using UILocalNotification
in iOS SDK) if you see on your device several local notifications fired by your app, you have to respond to all the alerts. N fired notification require to tap on N alerts.
This is very annoying. In my app the notifications are closely related between each other, so I would like to find a way to "consume" all the fired alert开发者_JAVA百科s by tapping only one alert. Is there a way?
An (almost) solution: at the end of didReceiveLocalNotification
(where you manage the single notification fired) if you cancel all the other notifications (via cancelAllLocalNotifications
) and the other alerts disappear. But in this way you cancel all the notifications, so you need to re-schedule the notifications not-fired.
Is there a less painful solution?
Thanks in advance
I think you will need to create your own alert handler. By this i mean, where you would normally throw an alert, call a method that will keep track of multiple alert like flags, and then when you could build in a timer that kicks off when the first alert is thrown and have it wait for other alerts. If no other alerts are thrown say within 10 seconds, then activate the system alert with a message built by your method. If multiple alert flags are thrown, then compile a composite message and then raise the alert with this composite message.
精彩评论