0

Estoy usando angular y ionic para crear mi apk, estoy integrando "onesignal" para las notificaciones push pero no quiere funcionar, no registra el dispositivo en la plataforma "onesignal". Ya he visto y leído varios tutoriales pero no encuentro el problema. Este es mi comido en mi app.component.ts

   initializeApp() {
    this.platform.ready().then(() => {
      this.statusBar.styleDefault();
      this.setupPush();
     });
    }

    setupPush() {

      this.oneSignal.startInit('949d218f-1a5d-4f1b-9dd0-ea8999076061', '883132740611');
  
      this.oneSignal.inFocusDisplaying(this.oneSignal.OSInFocusDisplayOption.None);
  
      this.oneSignal.handleNotificationReceived().subscribe(data => {
        let msg = data.payload.body;
        let title = data.payload.title;
        this.showAlert(title, msg);
      });
  
      this.oneSignal.handleNotificationOpened().subscribe(data => {
  
        this.showAlert('Notification opened', 'You already read this before');
      });
  
      this.oneSignal.endInit();
  }
 
  showAlert(title, msg) {
    this.alertCtrl.create({
      header: title,
      message: msg,
      buttons: [{
        text: "ok"
      }]
    }).then((ele) => {
      ele.present();
    })
  }

1 respuesta 1

0

Agrega esto:

OneSignal.setAppId("XXXX-XXXX-XXXX-XXXX-XXXX"); // Your APP ID
OneSignal.getDeviceState((stateChanges) => {
  console.log(
    "OneSignal getDeviceState: " + JSON.stringify(stateChanges)
  );
  if (stateChanges && stateChanges.hasNotificationPermission) {
    console.log("Player ID: " + stateChanges.userId);
  } else {
    console.log("Push notifications are disabled");
  }
});

El ID del remitente de Firebase no es necesario.

Tomado de: https://stackoverflow.com/questions/70813108/onesignal-issue-for-ionic-6-capacitor

Tu Respuesta

Al pulsar en “Publica tu respuesta”, muestras tu consentimiento a nuestros términos de servicio, política de privacidad y política de cookies

¿No es la respuesta que buscas? Examina otras preguntas con la etiqueta o formula tu propia pregunta.