Nick
Nick

Reputation: 3435

When do I schedule local notification

When the user leaves my iOS app, I want to schedule a local notification to remind him about my app. What is a correct place to do it? I cannot choose between

- (void)applicationWillResignActive:(UIApplication *)application

and

- (void)applicationDidEnterBackground:(UIApplication *)application

Or there's no difference in the case?

I also have a second question. When my app launches (either if user pressed notification, or from launchpad), I should obviously remove all that reminding notifications. I guess I should do it in

- (void)applicationDidBecomeActive:(UIApplication *)application

or

- (void)applicationWillEnterForeground:(UIApplication *)application

or maybe another method? Or it makes no difference again?

Upvotes: 0

Views: 133

Answers (1)

Wain
Wain

Reputation: 119031

Do it all in applicationWillEnterForeground. Remove any old notifications that don't matter now the user it engaged with the app and install any new notifications for after this use session. If the notification fires when the user is still using the app then you don't need to display anything (and the system won't display anything either).

Upvotes: 1

Related Questions