当app在后台时,如何将推送通知有效负载插入数据库

时间:2016-08-02 07:56:43

标签: ios objective-c push-notification background-fetch

当app在后台时,如何将推送通知有效负载数据插入数据库。我尝试了内容可用的标签,但它对我不起作用。 请帮帮我

1 个答案:

答案 0 :(得分:1)

还需要内容可用标记并使用此方法:

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {

    //add notification data to your database here

    completionHandler(UIBackgroundFetchResultNewData);
}

并将其添加到您的xcode。

enter image description here