ios - iOS 应用程序角标(Badge)中的随机数
<p><p>在设备或模拟器中安装并启动我的 iOS 应用程序后,应用程序图标一角的红色角标(Badge)会显示一个 5 位数字。</p>
<p>我已经好几个月没有注意到它了,然后安装了一些东西来启用本地通知(链接了标准的“PushNotificationsIOS”,安装了“react-native-push-notifications”)。</p>
<p>当我看到这个错误时,我删除了所有与通知相关的内容,但现在无论我在提交历史中追溯到多远,我都能看到它。以前每次通知后都会更改的数字,但现在是全新安装后稳定的 <code>61'051</code>。</p>
<p> <a href="/image/41fxe.png" rel="noreferrer noopener nofollow"><img src="/image/41fxe.png" alt="enter image description here"/></a> </p>
<p>我敢打赌,该设备仍然会发送数千个来自旧错误的通知,并且该数字是模数的结果。</p>
<p>什么会导致角标(Badge)出现这样的数字?什么没有被正确卸载?</p>
<p>否则,我可以完全移除角标(Badge)吗?</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>我相信您安排了许多本地通知,并希望摆脱它们。即使您删除了所有与通知相关的代码,但这并不意味着不会触发已安排的通知。所以你必须在你的代码中手动清理它们。
如果您使用 <code>iOS 10+</code> 通知,这可能会对您有所帮助:</p>
<pre><code>let center = UNUserNotificationCenter.current()
center.removeAllDeliveredNotifications()
center.removeAllPendingNotificationRequests()
</code></pre>
<p> <a href="https://developer.apple.com/documentation/usernotifications/unusernotificationcenter/1649509-removeallpendingnotificationrequ" rel="noreferrer noopener nofollow">Apple documentation</a> </p></p>
<p style="font-size: 20px;">关于ios - iOS 应用程序角标(Badge)中的随机数,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/49813411/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/49813411/
</a>
</p>
页:
[1]