首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用nativescript-angular在android和ios应用程序的通知中心清除通知?

如何使用nativescript-angular在android和ios应用程序的通知中心清除通知?
EN

Stack Overflow用户
提问于 2019-09-20 17:28:51
回答 2查看 299关注 0票数 0

Hai iam正在使用本地脚本开发android和ios应用程序。我正在为我的应用程序使用fcm通知,我想在单击按钮时清除通知中心中的通知。如何解决这个问题?

EN

回答 2

Stack Overflow用户

发布于 2019-09-20 20:41:52

最简单的选择是使用nativescript-local-notifications并使用cancelAll()方法。

代码语言:javascript
复制
LocalNotifications.cancelAll();
票数 1
EN

Stack Overflow用户

发布于 2021-07-02 01:50:54

代码语言:javascript
复制
// 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());
        }
    }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58025589

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档