且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

iOS重新安装应用程序无法清除徽章

更新时间:2023-02-21 22:28:00

徽章计数由操作系统维护,与应用程序无关.卸载(删除)应用程序后,操作系统会保留一些值,包括直到一天的徽章计数.卸载应用程序后,不会调用任何开发人员方法或脚本.实际上,苹果公司对此事有技术说明:这是摘录自 Apple的有关推送通知的官方技术说明:

The badge count is maintained by the operating system, independent of the app. When an app is uninstalled (deleted), some values are retained by the operating system, including the badge count until a day. When the app is uninstalled, no developer method or script is called. Actually there is a technical note from Apple about the matter: Here is the excerpt from Apple's official Technical Notes about push notifications:

启用推送功能的应用首次注册推送通知时,iOS询问用户是否希望接收该应用程序的通知.用户响应此警报后,将不会再显示该警报除非设备已还原或已在卸载了该应用至少一天.如果要模拟应用程序的首次运行,可以将应用程序卸载一天.您可以实现后者通过执行以下步骤,实际上无需等待一天的时间:

The first time a push-enabled app registers for push notifications, iOS asks the user if they wish to receive notifications for that app. Once the user has responded to this alert it is not presented again unless the device is restored or the app has been uninstalled for at least a day. If you want to simulate a first-time run of your app, you can leave the app uninstalled for a day. You can achieve the latter without actually waiting a day by following these steps:

  1. 从设备上删除您的应用.
  2. 完全关闭设备,然后重新打开.
  3. 转到设置">常规">日期和时间";安排时间并将日期提前一天或更长时间.
  4. 完全关闭设备,然后重新打开.