Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I got the clue to the solution for this from @naveed's tip on checking the state of the application when the didReceiveNotification method is called. No need to check variables etc when the app resumes from the background.</p> <p><strong>On iOS7 and lower</strong> you handle the notifications like this:</p> <pre><code>- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification { if (application.applicationState == UIApplicationStateInactive ) { //The application received the notification from an inactive state, i.e. the user tapped the "View" button for the alert. //If the visible view controller in your view controller stack isn't the one you need then show the right one. } if(application.applicationState == UIApplicationStateActive ) { //The application received a notification in the active state, so you can display an alert view or do something appropriate. } } </code></pre> <p><strong>Update for iOS 8:</strong> The following methods are now invoked when the app is opened from the background via a notification.</p> <pre><code>- (void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forLocalNotification:(UILocalNotification *)notification completionHandler:(void(^)())completionHandler { } - (void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forRemoteNotification:(NSDictionary *)userInfo completionHandler:(void(^)())completionHandler { } </code></pre> <p>If the notifications are received while the app is in the foreground, use the methods:</p> <pre><code>- (void) application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *) userInfo { } - (void) application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification { } </code></pre> <p>Note that there is no need to check application state unless you want to support older versions of the OS in your app.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload