如何将应用程序徽章编号设为0?(使用parse和swift)

nac*_*tel 3 xcode push-notification ios parse-platform swift

当我即将通过解析向我的应用发送推送通知时,它可以选择增加应用徽章.如果我打开并发送通知,应用徽章将继续越来越高.如何让徽章回到0?见图这里.

注意:如果答案是代码,请在swift中回答.

在此输入图像描述

And*_*tta 9

迅速

UIApplication.sharedApplication().applicationIconBadgeNumber = 0

Objective-C的

[UIApplication sharedApplication].applicationIconBadgeNumber = 0;

UPDATE

让PARSE知道它必须重置计数器执行以​​下操作(这也会重置设备上的本地徽章计数):

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