【问题标题】:How to clear push notification from Ionic Push?如何清除 Ionic Push 的推送通知?
【发布时间】:2015-07-07 00:17:56
【问题描述】:

当用户点击通知打开应用程序时,推送通知会清除。但是,如果用户打开应用程序,推送通知仍然存在。我怎样才能摆脱通知?我似乎在文档中找不到任何解决此问题的地方。

提前非常感谢

【问题讨论】:

    标签: push-notification ionic-framework ionic


    【解决方案1】:

    我做了一些挖掘,因为我也遇到了这个问题,它看起来像是 Push Plugin 中的一个错误。基本上他们将删除代码添加到暂停事件而不是恢复事件。

    你只需要更改src/android/com/plugin/gcm/PushPlugin.java中的代码

    来自:

    @Override
    public void onPause(boolean multitasking) {
        super.onPause(multitasking);
        gForeground = false;
        final NotificationManager notificationManager = (NotificationManager) cordova.getActivity().getSystemService(Context.NOTIFICATION_SERVICE);
        notificationManager.cancelAll();
    }
    
    @Override
    public void onResume(boolean multitasking) {
        super.onResume(multitasking);
        gForeground = true;
    }
    

    到:

    @Override
    public void onPause(boolean multitasking) {
        super.onPause(multitasking);
        gForeground = false;
    }
    
    @Override
    public void onResume(boolean multitasking) {
        super.onResume(multitasking);
        gForeground = true;
        final NotificationManager notificationManager = (NotificationManager) cordova.getActivity().getSystemService(Context.NOTIFICATION_SERVICE);
        notificationManager.cancelAll();
    }
    

    这将创建一个更标准的行为,在应用恢复时(而不是暂停时)将删除通知。但请注意,我尚未完全测试对内部应用消息的影响,这可能需要进行更多更改。

    【讨论】:

      猜你喜欢
      • 2020-04-04
      • 1970-01-01
      • 2015-08-07
      • 1970-01-01
      • 1970-01-01
      • 2017-02-05
      • 1970-01-01
      • 2017-06-01
      • 1970-01-01
      相关资源
      最近更新 更多