我正在从我的解析服务器发送通知,我想在用户打开应用程序时清除它们。我知道可以通过以下方式清除本地通知:
UIApplication.sharedApplication().cancelAllLocalNotifications()
但是这似乎不适用于推送通知。然而,
PFInstallation.currentInstallation().badge = 0;
用于清除角标(Badge)通知。
我像这样从 Parse 发送通知:
Parse.Push.send({
where: pushQuery,
data: {
alert: request.params.message,
sound: "default",
badge: 1
}
},{
success: function(){
console.log(" about to notify friend");
response.success("yes");
},
error: function (error) {
response.error("nope");
}
});
知道如何清除从 Parse 发送的通知(非本地通知)吗?
最佳答案
`cancelAllLocalNotifications`
-只会按照 iLikePancakes 的指示清除所有本地通知。
如果你想取消来自通知中心的所有通知,你首先需要将角标(Badge)编号增加到 1 或更高,然后将其设置回 0。在 AppDelegate didFinishLaunching
中使用它可以确保每次都会调用它
关于ios - .cancelAllLocalNotifications 是否清除推送通知?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35326020/