I am doing a project in which the push notification function is one of the key functions.
It works fine when I am in the application, I receive a notification and process this notification.
But the problem is that when I am in the background and receiving a notification, I see an icon on my application icon and when I click on the icon that launches my application, but the didReceiveRemoteNotification method didReceiveRemoteNotification not called, so I can not process this notification.
And another problem is that several times it shows a notification in the device notification list , but several times it is not.
When I enter my application by clicking on the notification list item, didReceiveRemoteNotification calls, and I can successfully process the notification. I am writing the following code in didFinishLaunchingWithOptions:(NSDictionary *)launchOptions method
NSDictionary* remoteNotif = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey]; if (remoteNotif != nil) { NSLog(@"didFinishLaunchingWithOptions\nNotification recieved:\n%@",remoteNotif); notificationData=[[NSDictionary alloc]initWithDictionary:remoteNotif]; [notif saveNotification:remoteNotif]; }
Help me solve this problem. Thanks in advance.
source share