I would like to set a UILocalNotification
that will disappear from the lock screen and the notification center after five minutes (if the user won't tap on it).
Can I set a timeout for the notification? Or maybe fire another notification that will delete it?
I believe Facebook does this by sending a silent push notification from their servers that triggers this code in the app:
[[UIApplication sharedApplication] setApplicationIconBadgeNumber: 0];
[[UIApplication sharedApplication] cancelAllLocalNotifications];
To keep the solution entirely local to the device, you can set an NSTimer
that can then trigger the above code at the proper interval. This comes with the huge caveat that if your app is suspended when in the background your timer won't fire until it is brought back an active state.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With