Rob Olmos
Rob Olmos

Reputation: 2432

Push Notification that cancels or reschedules a Local Notification?

We're investigating building an alarm-style iOS app as an extension of a website.

We plan to have alarms sent to the device via push notifications. We want to also have a local notification set to a time that's a little after the planned push notification just in case of no network connectivity and the push notification does not reach the user.

However, we would like to cancel this local notification and re-schedule it when the push notification is received so it doesn't annoy the user with an unnecessary notification.

Essentially two types of push notifications:

Is this a possibility?

Maybe with work-around such as being able to remain in the background like an audio app that only handles the push notifications and we could ask Apple for special approval?

How common it is to get special approvals like this?

Thanks

Upvotes: 2

Views: 420

Answers (1)

Myk Willis
Myk Willis

Reputation: 12879

I'm not sure, like Anthony Corbelli, what the reason for the push notification is if you're going to have the local notification set up for the same alarm.

In any case, if you want to cancel and/or reschedule an existing UILocalNotification from within the push notification handler, you can get a list of notifications with

[[UIApplication sharedApplication]scheduledLocalNotifications]

and then cancel the one you want with

[[UIApplication sharedApplication]cancelLocalNotification]

You can then modify the notification as desired (e.g., move its fireDate into the future) and reschedule it as appropriate.

Upvotes: 1

Related Questions