arnesson / cordova-plugin-firebase

Cordova plugin for Google Firebase
http://arnesson.github.io/cordova-plugin-firebase
MIT License
1k stars 1.55k forks source link

firebase push only work with opened app? #1139

Closed leabdalla closed 4 years ago

leabdalla commented 4 years ago

I've implemented FireBaseX in my Ionic 4 app to send remote notifications.

this.platform.ready().then(() => {
  let platforms = this.platform.platforms();

  if(platforms.includes('ios') || platforms.includes('android') || platforms.includes('mobile')){

    this.firebase.getToken().then(token => {
      console.log(`FIREBASE TOKEN ${token}`);
      if(platforms.includes('ios')) this.firebase.grantPermission();
    });

    this.firebase.onMessageReceived().subscribe(data => {
      console.log('FIREBASE MESSAGE', data);
    });

  }

});

So when I open the app in iOS, it asks for permissions correctly.

Then I send test message and the console.log() appears correctly.

2020-02-05 17:35:38.282123-0300 Parkaz[86464:2354851] didReceiveMessage: {
    "collapse_key" = "com.myapp.app";
    from = 678323471xxxx;
    notification =     {
        body = teste;
        e = 1;
        tag = "campaign_collapse_key_5659280550157990837";
        title = teste;
    };
}

However, if the app is not opened, nothing happens. The notification banner doesn't appear, no badge, no sound... nothing...

Am I doing something wrong?

betagole commented 3 years ago

How were you able to solve this? I've had this bug for months now. @leabdalla