ios在后台处理推送通知 [英] ios handle pushnotification in background
问题描述
我想保存应用程序处于后台状态时到达的推送通知.我知道
I want to save a push notification that arrives when the application is in background state. I know about
-(void) application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
当应用处于前台或后台时(如果用户只是点击收到的通知),将调用此委托方法.
This delegate method is called when the app is in foreground or background (if the user just clicks on the received notification).
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
此方法仅在应用启动时调用一次.
This method is called only once when the app starts.
如果用户没有点击通知怎么办?在这种情况下,如何将该通知的数据保存在我的应用程序的数据库中?
What if the user doesn't click on the notification? How can I save the data of that notification in the database of my app in that case?
推荐答案
对于这种情况,您无法将数据保存在[您的] 应用程序的数据库"中;相反,您将数据保存在服务器上的数据库中,这是首先生成 PushNotification 的地方.然后,当您的应用程序启动时,它会查询您的数据库以获取通知数据.
For this case, you can't save the data in the 'database of [your] app'; instead you save the data in the database on your server, which is where the PushNotification was generated in the first place. Then, when your App is started, it queries your database to get the notification data.
这篇关于ios在后台处理推送通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!