Сохранить уведомление Onesignal через хранилище ioni c, когда приложение закрыто - PullRequest
0 голосов
/ 21 марта 2020

Я пытаюсь сохранить уведомления Onesignal в моем приложении ioni c, но оно сохраняется только тогда, когда приложение находится в фокусе или в фоновом режиме. Он не сохраняет его, когда приложение закрыто и уведомление получено. Версия плагина 2.5.0 и платформа android. Я использую следующий код:

setupPush() {
    // I recommend to put these into your environment.ts
    this.oneSignal.startInit('APP_ID', 'GOOGLE_PROJECT_NUMBER');

    this.oneSignal.inFocusDisplaying(this.oneSignal.OSInFocusDisplayOption.None);

    // Notifcation was received in general
    this.oneSignal.handleNotificationReceived().subscribe(data => {
      console.log(data.payload);
      this.storage.ready().then(()=>{
        this.storage.get("notifications").then((res)=>{
          if(res == undefined)
            res = [];
          res.push({title: data.payload.title, body: data.payload.body});
          this.storage.set("notifications", res).catch((e)=>{
            console.log(e);
          });
        }).catch(e=>{
          console.log(e);
        });
      });
    });

    // Notification was really clicked/opened
    this.oneSignal.handleNotificationOpened().subscribe(data => {
      // Just a note that the data is a different place here!
      console.log(data);
      this.router.navigate(['notif']);
    });
    this.oneSignal.endInit();
  }
...