[IONIC 4] [OneSignal] Load Specific

Hi guys,

I’ve been stuck on this for a while & am in urgent need of some help!

I’m trying to load a specific page when a notification is clicked on when the app is not open.

Things to note:

  • the loadPage function works fine as I am calling it elsewhere
  • the if statement is defo trigged ( I have tried without it)
  • the detailid variable isn’t empty, ( I have tried hardcoding an id)
var self = this;

this.oneSignal
.startInit('000','000')
.inFocusDisplaying(this.oneSignal.OSInFocusDisplayOption.Notification)
.handleNotificationOpened(function (jsonData) {
    if (jsonData.payload.additionalData.template == 'news') {
        self.loadPage('/news-detail/' +  jsonData.payload.additionalData.detailid);
    }
})
.handleNotificationReceived(function (jsonData) { ... })
.endInit();

any help would be really appreciated!!

First thing I would do is get rid of every use of the keyword function in your code to eliminate execution context as a point of failure.