Obtain the OneSignal userId in the IONIC app

0

I need to access the UserId of a pushnotification component with the OneSiganl plugin in an Ionic application.

The provider where I do the initialization is called in app.component.ts. I create the service without problem and the notifications reach me.

The problem is that I need to save the userId that is obtained with getIds () on my login page. And I do not know how to access that value in my login component, if I have to re-start the service to access that Id or how to do it.

Thanks

    
asked by cmr 26.01.2018 в 14:03
source

1 answer

1

I did it this way, hopefully it will serve you:

id(){
    if(this.platform.is('cordova')){
      this.oneSignal.getIds().then(res=>{
        console.log(res.userId) . //===>ESTE ES TU ID
        this._us.dispositivo = res.userId;
        //AQUI LO GUARDAS EN TU STORAGE O DB
      });
    }
}
    
answered by 26.10.2018 в 22:24