0

I am working on push notification in iOS.

i use parse.com service for push notification.

when i send text notification all thing is good.

but when i terminate app by double tap home button and swipe app, then json notification not receive. (in other word method "application: didReceiveRemoteNotification:" not called).

i use NSLog code to check notification receive and monitoring device consol.

-(void)application:(UIApplication *)application didReceiveRemoteNotification:(nonnull NSDictionary *)userInfo{
      NSLog(@"Receive notification in didReceiveRemoteNotification %@", userInfo);
}

i read all similar problem in stackoverflow postes but answer not found.

Edit 1:

I enabled Background mode -> remote notification

Dr. chamran
  • 540
  • 4
  • 11
  • Possible duplicate of [Receiving Push Notifications while in background](http://stackoverflow.com/questions/14616261/receiving-push-notifications-while-in-background) – Rohit Pradhan Jan 23 '16 at 07:14
  • Did you turn on push notification enabled on your project settings? – Ajumal Jan 23 '16 at 07:20
  • YES. I enabled Background mode -> remote notification – Dr. chamran Jan 23 '16 at 07:27
  • Try push notification without using any third party. – Ajumal Jan 23 '16 at 07:39
  • i should use parse.com because notification panel written before – Dr. chamran Jan 23 '16 at 07:43
  • When your app is terminated, `application:didReceiveRemoteNotification:` will not be called. Instead `application:didFinishLaunchingWithOptions:` will be called from which you can receive the Push notification payload as mentioned in this [answer](http://stackoverflow.com/questions/34923452/accessing-push-payload-if-app-is-inactive) – UditS Jan 23 '16 at 08:28
  • If you check your device's console logs after killing the app, you'll see that it tells you that it won't wake the app to process the background notification. That is, iOS specifically chooses not to wake your app because you killed it manually. – Avi Jan 23 '16 at 16:17
  • @Avi: i can not understand your mention. if NSLog can not log because app is killed, so i can not do anything(for example process notification Json) because app is killed! – Dr. chamran Jan 24 '16 at 06:57
  • You are correct. If you explicitly kill the app by double-tapping the Home button and swiping the app away, iOS will not launch your app for incoming notifications. At some point it will choose to do so, perhaps after you've relaunched the app yourself. I have not tested enough to determine this. – Avi Jan 24 '16 at 07:13
  • 1
    In other words, I am telling you that the behavior you are seeing is by design. It's not a bug in your code and there's absolutely nothing you can do about it. – Avi Jan 24 '16 at 07:14
  • @Avi: yes sir. I hate Apple. Android is Best for developer and users. – Dr. chamran Jan 24 '16 at 07:27
  • Android is great for developers, which is why it's horrible for users. You hate Apple because Apple doesn't care about you. Apple cares about the users first. As both a user and a developer, I appreciate their position. – Avi Jan 24 '16 at 08:04

1 Answers1

0

when your app is in background Remote notification receive, but "application: didReceiveRemoteNotification:" not called Right?

& enable Background Mode

in

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
UIUserNotificationType userNotificationTypes = (UIUserNotificationTypeAlert |
                                                UIUserNotificationTypeBadge |
                                                UIUserNotificationTypeSound);
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:userNotificationTypes
                                                                         categories:nil];
[application registerUserNotificationSettings:settings];
[application registerForRemoteNotifications];
  // Extract the notification data
NSDictionary *notificationPayload = launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey];
}