Hai iam正在使用本地脚本开发android和ios应用程序。我正在为我的应用程序使用fcm通知,我想在单击按钮时清除通知中心中的通知。如何解决这个问题?
发布于 2019-09-20 20:41:52
最简单的选择是使用nativescript-local-notifications并使用cancelAll()方法。
LocalNotifications.cancelAll();发布于 2021-07-02 01:50:54
// Best solution is as below for the devices >= Marshmello.
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
for (StatusBarNotification statusBarNotification : notificationManager.getActiveNotifications()) {
// if (KEY_MESSAGE_GROUP.equals(statusBarNotification.getGroupKey()))
logApp(TAG, "deleteAllNotifications(), statusBarNotification.getId()- "+statusBarNotification.getId());
notificationManager.cancel(statusBarNotification.getId());
}
}https://stackoverflow.com/questions/58025589
复制相似问题