我正在做一个项目,其中推送通知功能是关键功能之一。
当我在应用程序中时它工作正常,我收到通知并处理该通知。
但问题是当我在后台并收到通知时,我在我的应用程序图标上看到了徽章,当我点击我的应用程序正在启动的图标时,但didReceiveRemoteNotification
没有调用该方法,因此我无法处理该通知。
另一个问题是有时它会显示通知消息,device notification list
有时却没有。
当我通过单击通知列表项进入我的应用程序时didReceiveRemoteNotification
,我可以成功处理通知。我写下面的代码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];
}
帮我解决这个问题。提前致谢。