fechanique / cordova-plugin-fcm

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

Missing out on Notifications from the tray #595

Open marcgfx opened 4 years ago

marcgfx commented 4 years ago

First of all, thanks for the plugin. I just switched from phonegap-push-plugin that no longer seems to be supported and currently is not working for android.

cordova plugin add cordova-plugin-fcm-with-dependecy-updated I also needed to update to com.google.firebase:firebase-core:16.0.0 com.google.firebase:firebase-messaging:17.3.4 com.google.gms:google-services:3.2.1 as there was an exception when messages are received in the background

As I could not get the main branch to work. I think I could not get it to work, because I did not understand the initialization of FCMPlugin, as it is not ready/available when deviceready is called.

So I am receiving the push notifications. When not in the app the notifications go to the system tray (but only with notification:{title:"xxx",body:"xxx"} set). When clicking on the notification, nothing happens in the app, although I do have a data object too. With only data object, I don't get anything in the system tray (even when setting title, body in the data object).

The question I am asking myself: How am I supposed to initialize the FCMPlugin, when do I set the callbacks?

Currently I do this ugly thing, that would repeat in case it's still not ready: setTimeout(prepareFCM,200);

So I kind of miss out on the initialization of the FCMPlugin and I'm wondering it there might be a onNotification that I also miss due to this fact.

marcgfx commented 4 years ago

Just fixed my own issue by reading other peoples issues. I was missing: "click_action":"FCM_PLUGIN_ACTIVITY" in my notification object

Franco-Alejandro commented 4 years ago

Hey! @marcgfx hope you're doing fine! I kinda noticed that this repo is abandoned... I'm working on a mobile app that uses FCM. I was wondering if you could explain to me how did you do to make the plugin work... it's asking me to downgrade most of my firebase dependencies and because I'm new to Ionic and Cordova, in general, I don't really know if I have to change the plugin itself or what.

marcgfx commented 4 years ago

not sure what I can tell you, that i did not say above. I replaced all dependencies in the android project as stated above, simply look for the corresponding information using the search function and replace the versions text. I did not know what I was doing (still dont), but it worked.

com.google.firebase:firebase-core:16.0.0 com.google.firebase:firebase-messaging:17.3.4 com.google.gms:google-services:3.2.1

I use following plugin, not the one from this repository:

cordova plugin add cordova-plugin-fcm-with-dependecy-updated

Franco-Alejandro commented 4 years ago

nice! thanks for the quick response, I'll try it out!