gpt4 book ai didi

ios - 如何在 Parse 中重置 iOS 推送通知角标(Badge)编号?

转载 作者:可可西里 更新时间:2023-11-01 04:45:56 25 4
gpt4 key购买 nike

我正在使用 Parse iOS SDK。我在重置角标(Badge)计数时遇到问题。我正在使用教程(解析)代码发送推送通知。我对角标(Badge)使用增量,但角标(Badge)计数一直在增加。我正在 applicationDidBecomeActive: 方法中重置角标(Badge)计数,

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

PFInstallation *currentInstallation = [PFInstallation currentInstallation];

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

// ...
}

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

最佳答案

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

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

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

这就是我解决不同步角标(Badge)的方法。

关于ios - 如何在 Parse 中重置 iOS 推送通知角标(Badge)编号?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28840050/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com