ios - .cancelAllLocalNotifications 是否清除推送通知?

标签 ios swift parse-platform

我正在从我的解析服务器发送通知,我想在用户打开应用程序时清除它们。我知道可以通过以下方式清除本地通知:

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/

相关文章:

ios - 当我在 Parse 中创建任何对象时,createdAt 属性不是正确的创建时间。

ios - Firebase 数据库不工作

ios - 如何截取uiview的屏幕截图并快速拖动?

ios - Xcode build设置和 Scheme 环境变量之间的区别

ios - i18n 与 Cocoapods 和动态库

swift - 访问功能(成员)的按钮名称

swift - 如何在 Parse 中查找名字和姓氏

swift - 如何使用 Parse 子类和 User 之间的关系 - Swift

objective-c - iOS mapview - 添加注释时出现问题

iphone - viewDidLoad 中的 NSURLRequest 使用缓存数据?