fechanique / cordova-plugin-fcm

Google FCM Push Notifications Cordova Plugin
624 stars 991 forks source link

IOS can receive notification but on FCMPlugin.onNotification & data.wasTapped is not working when app is in background. #608

Open nitishbhardwaj1111 opened 4 years ago

nitishbhardwaj1111 commented 4 years ago

Hi,

I am trying to redirect to a particular page when clicking on notification. It is working fine with local notification. It also working fine with FCM when app is closed.

But if the app is in background i am able to get the notification in notification tray but clicking on it is not redirecting to the particular page. it just opens the app and show the default opening page.

i am also not able to see the data coming from notification, as quitting the app closes the debugger and as soon as i click on notification, the console does not store the the previous consoles as android app do.

this.platform.ready().then(() => {
      setTimeout(() => {
        this.fcm.onNotification().subscribe(async data => {
          console.log("FCM notification data", data);
          if (data.wasTapped) {
            const loginData: any = await this.storageProvider.getLoginData();
            console.log('data.wasTapped', data);
            if (data.key === "horse") {
              const sendData = data;
              this.nav.setRoot("TabsPage", { data: sendData }, { animate: true, direction: 'forward', duration: 500 });
            }
          }
        });
      }, 1000);
    });
DhyeyMoliya commented 4 years ago

Same here. @nitish75 have you resolved this error?

nitishbhardwaj1111 commented 4 years ago

@DhyeyMoliya No not yet, Actually the FCM this.fcm.onNotification().subscribe is not subscribing.

ProximaHaiz commented 4 years ago

If you are using cordova-plugin-local-notification or cordova-plugin-background-geolocation read this https://github.com/fechanique/cordova-plugin-fcm/issues/509#issuecomment-544129115