0
votes

I have tried silent Apple push notification in ios 7 using following code. The Push notification received when application is in foreground or in background. Then I remove application from background by swiping the application from background apps. After that If I send a Push notification from my server, it sent to APN properly, but not delivered to iPhone.So Apple push notification in ios 7 delivers silent push notification only application running in backgroud? If user remove application from background will it receive notification or not?

-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
{
    NSString *receivedMessage = [[userInfo objectForKey:@"acme1"] objectForKey:@"mydata"];
    NSLog(@"fetchCompletionHandler receivedMessage -> %@",receivedMessage);
    completionHandler(UIBackgroundFetchResultNewData);
}
2
Please check my answer here, stackoverflow.com/questions/18856204/…Nandha
@Nandha,so if i remove application from switcher(force quit app),then apple push notification will not receive?Ramprasad
Yes you will not receive push notification as long as your app in "Not Running" state.Nandha
@Ramprasad you are correct. If you remove the app from the app switcher your app won't receive silent push at all. The official Apple explanation is they do that to let the user be able to kill and app that is misbehaving. He can re enable the app anytime by entering the app again, which will also re enable the background behaviour (silent push in your case). Also, there is currently a bug with silent push, that if your app was running and you reboot your phone, silent push won't reach the device until the user re opens the app manually: devforums.apple.com/thread/209664?tstart=0mp3821

2 Answers

0
votes

didReceiveRemoteNotification not called when app will not run,it only called when app will open and foreground.

you will get list of notifications in UILocalNotification,if app not run and it receive notifications like this :

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

     UILocalNotification *localNotif =[launchOptions objectForKey: UIApplicationLaunchOptionsRemoteNotificationKey];
        if (localNotif) {

            NSLog(@"****** notifiation ******");
     }
       return YES;
   }
-1
votes

App will be able to receive the notification even when app is closed i.e. not in background mode.