Reputation: 2158
I have an app with scheduled notifications that need to be cancelled after 5 minutes if not interacted with.
In other words, a scheduled local notification is displayed (e.g. in lock screen), and if the user doesn't do anything (slide-to-read or go to the app), then call cancelAllLocalNotifications
.
How would you attempt to solve this?
Thanks in advance!
Upvotes: 1
Views: 335
Reputation: 135578
You can't modify scheduled notifications while your app is in the background.
In other words, a scheduled local notification is displayed (e.g. in lock screen), and if the user doesn't do anything (slide-to-read or go to the app), then call
cancelAllLocalNotifications
.
If I understand you correctly, there should be no further notifications if the user doesn't do anything. And if the user launches your app again, there should be further notifications scheduled. The solution to this seems simple. Only schedule the one notification. If the user doesn't react to it, you don't have to cancel anything. If the user reacts, schedule the other notification(s) right when your app comes to the foreground.
Upvotes: 1