如何在Parse中重置iOS推送通知徽章号码?

时间:2015-03-03 19:14:40

标签: ios objective-c parse-platform push-notification xcode6

我正在使用Parse iOS SDK。我在重置徽章计数时遇到问题。我正在使用教程(解析)代码发送推送通知。我使用增量徽章,但徽章计数继续递增。我正在重新设置applicationDidBecomeActive中的徽章数:这样的方法,

- (void)applicationDidBecomeActive:(UIApplication *)application { 

    PFInstallation *currentInstallation = [PFInstallation currentInstallation];

    if (currentInstallation.badge != 0) {
        currentInstallation.badge = 0;
        [currentInstallation saveEventually];
    }

// ...
}

它只是在本地重置徽章编号。但是当我下次发送推送通知时,它只是增加先前的计数值并显示它。我猜Parse服务器中的徽章编号没有被重置。此外,我尝试使用[currentInstallation saveInBackground];,但它也不起作用。帮助

1 个答案:

答案 0 :(得分:2)

尝试不使用if语句(如果您不介意不必要的api请求):

PFInstallation *currentInstallation = [PFInstallation currentInstallation];
currentInstallation.badge = 0;
[currentInstallation saveEventually];

似乎有时installation.badge != 0检查失败。

这就是我解决了我的徽章的方法。

相关问题