0

Can we receive remote push notifications when the application is not running in foreground or background. Basically the application is killed?

Eran
  • 387,369
  • 54
  • 702
  • 768
Blue
  • 177
  • 2
  • 8
  • possible duplicate of [how can I handle push notification when my app is not running](http://stackoverflow.com/questions/4782352/how-can-i-handle-push-notification-when-my-app-is-not-running) – mechanical_meat Apr 24 '12 at 16:51

3 Answers3

0

Yes, you will still receive push notification even the app is not running.

Jason
  • 814
  • 1
  • 6
  • 15
  • Your app will only receive notification directly if it is running in the foreground in any other situation iOS wil display a message to the user that a notification is received. And only after the user select the notification for you app will your app be launched. – rckoenes Apr 24 '12 at 14:34
  • @rckoenes you are right. But mine is right as well. When you app is not running, your phone will still receive push notification when there is one for your app. – Jason Apr 24 '12 at 16:22
0

If a notification for an application arrives when that application is not running, the device alerts the user that the application has data waiting for it.

Bobj-C
  • 5,276
  • 9
  • 47
  • 83
0

No if the message is received it will not start your app, it is handled by iOS.

You app wil get launched if the user selects to view the notification. Thus if the user does not react to the notifications your app will not be launched. If iOS start your app when the user selected a push notification for your app you will have to check the lauchOptions dictonary to see if there are any push notifications:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
    // Override point for customization after application launch.
    _rootViewController = [[RootViewController alloc] init];

    self.window.rootViewController = self.rootViewController;   

        NSDictionary *remoteNotif = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];

    if (remoteNotif) {
        //Handle notification
    } 
}

If your app is already running and in the foreground than the app delegate will receive the notification directly. The method - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo is called on your app delegate.

rckoenes
  • 69,092
  • 8
  • 134
  • 166