Ryan Caskey
Ryan Caskey

Reputation: 217

What is the best way to modify a UILocalNotification after it has fired?

I understand that you cannot modify a UILocalNotification after it has been scheduled. My problem is that I want to set the .repeatInterval so that it fires at a specific time once per day. However I want the content to change every day. So the user sets the alarm to fire at 10AM, and every day at 10AM gets an alert with different content without having to reset their alarm.

I was thinking about canceling and rescheduling when didReceiveLocalNotification was called but that requires the user to launch the app before the next scheduled alert. Is there a way to call a method immediately after the alert is fired?

Upvotes: 2

Views: 129

Answers (1)

matt
matt

Reputation: 534893

Unfortunately you have no certain way of knowing that a local notification has fired unless your app is frontmost at the time it fires.

And, as you say, you cannot change a notification.

So I think your best bet is do not use repeating notifications. Set up a different single notification for each day, say, two weeks ahead, with different messages for each, and hope the user runs the app between now and then so that you can "refresh" the queue, as it were. Maybe make only the last one repeating, just in case, so that the notifications never stop - but of course then the message will be same each time. But there's nothing you can do about that. You can't force the user to run the app.

Upvotes: 4

Related Questions