清除通知欄所有通知
//只要設(shè)置角標(biāo)不相同時臊泰,再設(shè)置為0就可以清除
[UIApplication sharedApplication].applicationIconBadgeNumber = 1;
[UIApplication sharedApplication].applicationIconBadgeNumber = 0;
推送通知進(jìn)入后臺處理通知消息
1.后臺推送消息設(shè)置,要再推送消息中加入鍵值對"content-available" = 1迷捧。這種方式為靜默推送
例如:
aps = {
alert = "一條新的消息";
"content-available" = 1;
sound = default;
};
2.App端的需要遠(yuǎn)程通知后臺模式坎吻,在plist添加如下key
<key>UIBackgroundModes</key>
<array>
<string>fetch</string>
<string>remote-notification</string>
</array>
消息處理在如下方法回調(diào)中
- (void)application:(UIApplication *)application
didReceiveRemoteNotification:(NSDictionary *)userInfo
fetchCompletionHandler:
(void (^)(UIBackgroundFetchResult))completionHandler {
NSLog(@"收到推送通知:%@", userInfo);
completionHandler(UIBackgroundFetchResultNewData);
}