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

Igo*_*aev 5 objective-c push-notification ios parse-platform xcode6

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

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

    PFInstallation *currentInstallation = [PFInstallation currentInstallation];

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

// ...
}
Run Code Online (Sandbox Code Playgroud)

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

Eri*_*net 3

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

PFInstallation *currentInstallation = [PFInstallation currentInstallation];
currentInstallation.badge = 0;
[currentInstallation saveEventually];
Run Code Online (Sandbox Code Playgroud)

好像有时候installation.badge != 0检查会失败。

这就是我解决徽章不同步问题的方法。