【问题标题】:How do I disable "cordova-plugin-local-notifications" notifications after closing an app created with Cordova?如何在关闭使用 Cordova 创建的应用程序后禁用“cordova-plugin-local-notifications”通知?
【发布时间】:2022-10-01 01:14:06
【问题描述】:
  • iOS14.0
  • cordova-plugin-local-notifications0.9.0-beta.2

你好。抱歉翻译不佳。

我正在使用 Cordova 开发应用程序并使用 \"cordova-plugin-local-notifications\" 插件来实现本地通知。

目前,我在应用程序移到后台 10 秒后输出本地通知, 我写了以下内容


  cordova.plugins.notification.local.schedule({
    id: 1,
    title: \"Test\",
    text: \"Test Message.\",
    trigger: {unit:\"second\", in:10}
  });

如果我们实现这个过程,即使在应用程序关闭后也会输出本地通知。

关闭应用程序后如何防止本地通知输出?

    标签: ios cordova cordova-plugins localnotification


    【解决方案1】:

    当用户关闭应用程序时,您需要清除待处理的通知,尝试

     window.addEventListener('beforeunload', function(event) {
          cordova.plugins.notification.local.clear();
     });
    

    我不确定是clear 还是clearAll

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-12-02
      • 1970-01-01
      • 1970-01-01
      • 2019-02-15
      • 2017-09-03
      • 1970-01-01
      • 2016-07-27
      • 2017-02-17
      相关资源
      最近更新 更多