I have a UILocalNotification set up, and as far as i can see it i have 5 different scenarios:
- The app is not running, the user chooses to view the notification, so it launches the app.
- The app is not running, the user chooses to close the notification, then opens the app at a later date.
- The app is running in the background, the user chooses to view the notification, so it brings the app to the foreground.
- The app is running in the background, the user chooses to close the notification, then opens the app bringing it to the foreground at a later date.
- The app is running in the foreground.
How do i deal with these 5 different scenarios?
Put your code into
application:didFinishLaunchingWithOptions:. Inthe actions
NSDictionaryyou will find the information about thenotification.
You can again check in
application:didFinishLaunchingWithOptions:if the localnotification is still active and take appropriate action.
Put your code into
applicationWillEnterForeground:Again the same spot, just check if there are active local notifications.
Here you can check in
application:didReceiveLocalNotification:and either notify the user or not.