Can't add subsribers to onesignal project


#1

As mentioned in the title i can’t subscribe to my onesignal project from my devie.
when i launch the app it shows 2 alerts saying ( making request and request successfully finished )
but suddenly the app closes.
my platform is android 7.1.0 with onesignal 2.4.1

the code used

window["plugins"].OneSignal.setLogLevel({logLevel: 6, visualLevel: 6});
      var notificationOpenedCallback = function(jsonData) {
        console.log('notificationOpenedCallback: ' + JSON.stringify(jsonData));
      };

      window["plugins"].OneSignal.startInit("4c848104-daba-448e-bd62-a2b64b565a87", "985484105915");
      window["plugins"].OneSignal.handleNotificationOpened(notificationOpenedCallback);
      window["plugins"].OneSignal.endInit();

#2

First question, are you using the Ionic Native onesignal plugin?

If yes, this is what works for me:

import { Onesignal } from '@ionic-native/onesignal'
...
constructor(
    private _SIGNAL: Onesignal;
){
   this.platform
   .ready()
   .then(src => {
        this.init();
        _SIGNAL.setLogLevel({ logLevel: 6, visualLevel: 6 });
...
    });
}

init() {
    this._SIGNAL.startInit(APP_ID, GOOGLE_PROJECT_ID);

    this._SIGNAL.handleNotificationOpened().subscribe((info) => {
        console.log('Notification Opened', JSON.stringify(info));
    });

    this._SIGNAL.endInit();
}

#3

Tried your code but it still show the same behavior :confused:
Actually, the endinit() function closes the app, i tried commenting it and the app doesn’t crash …