如何在Ionic 3&amp ;;中打开app上的通知Cordova OneSignal插件?

时间:2018-01-22 16:30:53

标签: cordova ionic3 onesignal

我使用OneSignal在Ionic 3 APP中发送接收通知。

我的代码是(完美运作)

this.oneSignal.startInit(Config.oneSignal.appId, Config.oneSignal.firebaseSenderId);
    this.oneSignal.inFocusDisplaying(this.oneSignal.OSInFocusDisplayOption.None);
    this.oneSignal.handleNotificationReceived().subscribe((data: any) => {
      const attempt = data.payload.additionalData.attempt;
      if (data.isAppInFocus) {
        this.presentModalDefense(attempt);
        this.oneSignal.cancelNotification(data.androidNotificationId);
      } else {
        this.badge.increase(1).then(data => {
          console.log(data);
        });
      }

    });

    this.oneSignal.handleNotificationOpened().subscribe((data: any) => {
      const attempt = data.notification.payload.additionalData.attempt;
      if (!data.isAppInFocus) {
        this.attemptProvider.howLongTimeAgo(attempt.id).subscribe((timeago: any) => {
          let config = this.auth.getConfig();
          if (timeago.seconds >= config["SPEED_TO_ROB"].value) {
            this.presentModalUnsuccessfulDefense(attempt);
          } else {
            this.presentModalDefense(attempt, timeago.seconds);
          }
        }, err => {

        });
      }
    });
    this.oneSignal.endInit();

我的问题是

我想拨打this.oneSignal.handleNotificationOpened()(对于尚未处理的所有待处理通知)

  1. 如果用户点击APP图标(在这种情况下寻找解决方案)
  2. 如果用户点击通知(此案例工作)
  3. 有人知道怎么做吗?

0 个答案:

没有答案