首页 > 解决方案 > 在 IOS 设备中的 ionic 4 本地通知上捕获点击事件

问题描述

在我的ionic 4应用程序中,我能够使用cordova本地通知插件(doc.)在按钮单击时触发本地通知,但无法找到在用户单击通知横幅时捕获事件的方法。单击通知时,它只会重定向到应用程序,但不会进入'on click'功能。在 android 设备上测试时它工作正常,但在 ios 上没有运气。

在此先感谢您的帮助。

这是我的代码:

  constructor(
    private localNotifications: LocalNotifications,
    public platform: Platform,
  ) {
     this.platform.ready().then(() => {
       this.localNotifications.on('click').subscribe(notification => {
         console.log('click on notification fired);
     });
  }

  notify() {
    this.localNotifications.schedule({
      title: `my test notification`,
      text: `my detailed description`,
      trigger: {
        in: 3000,
        unit: ELocalNotificationTriggerUnit.SECOND,
      },
    });
   }

这是我的离子信息:

Ionic:
   Ionic CLI                     : 5.4.5 (/usr/local/lib/node_modules/ionic)
   Ionic Framework               : @ionic/angular 4.11.5
   @angular-devkit/build-angular : 0.801.3
   @angular-devkit/schematics    : 8.1.3
   @angular/cli                  : 8.1.3
   @ionic/angular-toolkit        : 2.0.0

Cordova:

   Cordova CLI       : 7.0.0
   Cordova Platforms : android 8.0.0, browser 6.0.0, ios 4.4.0
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.1.3, (and 10 other plugins)

标签: cordovaionic-frameworkcordova-pluginsionic4

解决方案


我试图通过“ionic Devapp”运行我的应用程序,结果它在 Devapp 中不起作用。

当我尝试使用它运行它时,ionic cordova run ios它工作正常。


推荐阅读