我正在使用 react-native-push-notification在我的 React Native 应用程序中触发本地通知的模块。
在 PushNotification.localNotification(details)
中,details
对象采用一个 id
属性,然后可以使用该属性清除本地通知。
我想知道的是:这些 ID 是由手机上运行的所有应用程序共享的,还是特定于 React Native 应用程序的?
基本上我想知道我是否需要使其随机以便它不会与另一个应用程序冲突,或者它是否可以只是一个特定于我的应用程序的 ID 每次递增?
最佳答案
因为它是本地通知,所以我假设它使用 NotificationManager.notify发送它。
Android 文档是这样说的:
Post a notification to be shown in the status bar. If a notification with the same id has already been posted by your application and has not yet been canceled, it will be replaced by the updated information.
您的应用的 ID 应该是唯一的。
关于android - 本地通知的ID是否需要全局唯一?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47501311/