问题描述
我在做其中的项目推送通知功能是主要特征之一。结果
它工作正常,当我在应用程序,我收到通知并处理通知。
但问题是,当我在后台和通知接收我看徽章在我的应用程序图标
当我点击该图标我的应用程序正在启动,但 didReceiveRemoteNotification
方法不叫,所以我不能处理的通知。
和另外一个问题是,有些时候,它显示了在设备通知列表
有的时候它也没通知消息。
当我在我的应用程序通过点击通知列表项的 didReceiveRemoteNotification
通话进入,我能够成功处理通知。
我写下面code在 didFinishLaunchingWithOptions:(NSDictionary的*)launchOptions方法
的NSDictionary * remoteNotif = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
如果(remoteNotif!=无)
{
的NSLog(@didFinishLaunchingWithOptions \\ nNotification收到:\\ n%@,remoteNotif); notificationData = [[NSDictionary的页头] initWithDictionary:remoteNotif];
[notif saveNotification:remoteNotif];
}
帮我解决这个问题。
先谢谢了。
从苹果公司的本地和推送通知编程指南
So in your case, when application is running in background, and when you click the notification/alert, operating system brings your app into foreground. So it falls under second point.
You can implement application:didReceiveRemoteNotification:
method to get the notification payload, if action button is tapped. But when the application icon is pressed instead of action message, the notification payload is not forwarded with the method. Your only option is to contact your server and sync the data. After all as per Apple's policy, push notification only tells that there is data on server, and either way you need to connect to server and get the data.
这篇关于iOS的推送通知的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!