-
-
Notifications
You must be signed in to change notification settings - Fork 105
FCM adapter #32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
We could add a new handler here for fcm, so it processes properly fcm based push alongside GCM. The FCM compatible installations will have pushType set to fcm instead of gcm. What do you think? |
That'd be perfect! Wish I could help in some way. |
No need for the FCM adapter, just initialize with the right key and the GCM adapter pushes will automagically send everything correctly! |
Don't you need a serverapi key and a project number? I don't think firebase supplies the project number or key. |
Nevermind, Firebase creates a senderId and Server Api Key which can be found in the project settings. |
Do we still have to add firebase to our projects? I set the senderId and apiKey found in Firebase but the message wasn't pushed. |
Does the token was acquired with the firebase SDK? Not sure about the compatibility here |
When setting up fcm, the Firebase console automatically creates a senderId and a serverApiKey. |
I means the android device tokens. Maybe we should still let gcm and fcm token live separately. |
Oh, I haven't added the Firebase sdk to my app so the token must be generated by parse. Basically, I'm running parse-server as usual but have setup fcm (which created a serverkey and senderId). I'm then placing that key and id in parse-server just like I would with gcm key and id. Sorry for the confusion. |
All device tokens acquired with GCM should work with FCM. But if you changed your senderID and serverKey, that's likely to be problematic IMHO yet I'm not sure |
The thing is I haven't setup gcm with parse-server. I was using push through hosted parse but it didn't require me to create an app for gcm. Now the only option we have is to add fcm instead of gcm and it doesn't seem to be working. I setup my parse app (and server side) just like how you would with gcm and added the fcm credentials to it, which is really only the server key but that shouldn't be any different. |
@inlined may have more input on that. |
Ok, I think I've figured it out finally. There is a little more setup, however when adding fcm to your android project (if you haven't already setup gcm) you can keep your parse push configuration the same in the androidmanifest.xml but you have to add the firebase library to your project. This allows receiving message and customizing receiver service because fcm message doesn't show up when app is in foreground. I followed this page and got it working https://firebase.google.com/docs/notifications/android/console-audience |
I seem to be able to receive notifications but sending them doesn't work. |
Nevermind, I had forgotten the meta-data for gcm_sender_id at the bottom of manifest. Everything has remained the same as far as parse push. |
@thailey01 by "Adding Firebase your project", do you mean just adding the import in gradle or did you also implement the FirebaseMessagingService? Also, what library did you import, the core, messaging or both? |
In the end, I found out that you don't even need to import any library while using parse-server. I was missing the meta-data tag in my manifest and everything worked fine. |
Thailey were you using device->device pushes or device->parse-server->device pushes ? This solution here does not make any sense based on current adapter. Seems you were not using adapter at all to send and recieve pushes. So changing adapter to support FCM is still valid issue, because it uses npm-gcm, but should use npm-fcm library for new users. |
As I'm using parse-server I am calling a cloud function from my native app to send push notifications. The adapter as it is now seems to support fcm just the same as gcm. I changed absolutely nothing from the current documentation for setting up parse-server push. |
What values do you use in parse-server config file ? I have these fields and it seems not to work with default adapter. {"android": { |
Those are the same I use, found from the firebase console settings page. Be On Sep 13, 2016 5:34 PM, "kiis" notifications@github.com wrote:
|
ok, server side seems the same, manifest has meta tag. Still shows that android pushes are not delivered. In database installation table do you have deviceToken or GCMSenderId for android users ? |
Device token |
could you show your index.js and manifest file? |
In addition, I don't know if you actually have it that way, but I don't put quotes around my keys in my config. Such as: |
Manifest: http://pastebin.com/FAcCrAkC Server is using pm2 and it has config differently listed, but it works and ios pushes also. |
The only difference I see between your manifest and mine is that I specify ParseBroadcastReceiver |
added it, but there is still null value in isntallation table for field deviceToken |
I was also getting null value returned for the deviceToken. My case was terrible, sometimes, it returns null, sometimes, it returns a value. what i did was to clean the project as instant run in android studio is quite buggy. |
Are you calling ParseInstallation.getCurrentInstallation().saveInBackground() when you setup parse-server config In your app? I do mine in a class that extends Application. |
Found the issue. Adapter works perfectly. The issue is java.lang.Exception: GCM registration error: INVALID_SENDER . Seems FCM SenderId is not accepted in GCM server by Android SDK. Now im manually copying GCMSenderId to deviceToken field afterSave in cloud code. |
That a little bit of a hassle, but I'm glad you figured out the problem. I don't know why I didn't have it though. |
Disclaimer: This is the first time I'm implementing push notifications. Hey there! Thanks guys :) edit: I just tried using the master branch.
Still, on the device I don't receive any notification (sending the push through the firebase console works though). Thank you guys, let me know if I can help in any way :) |
We are creating an application using This is the body of the notification we are sending:
I read about it in multiple places but seems like we need to have a FCM adapter that knows how to handle FCM push notifications. I debugged the GCM push adapter and does not have any clue or whatsoever of what a
any thoughts? what shall we do? Is there a way to continue to use parse-server and get notifications sent AND DISPLAYED to Android devices? Do I need to tell the Android dev to change something in the app settings??? where? what? Any help would be appreciated. Thanks in advance |
As you mention, the current adapter works with FCM, just the notification field is missing. |
But without |
There is no need to use the fcm branch, the master branch should work correctly with fcm |
Mhhh...could you explain me a bit further? If I use
FYI...I am |
See the node-gcm documentation here: https://www.npmjs.com/package/node-gcm The notification key is not set when creating the gcm.message here: https://github.com/parse-server-modules/parse-server-push-adapter/blob/master/src/GCM.js#L124 and here: https://github.com/parse-server-modules/parse-server-push-adapter/blob/master/src/GCM.js#L60 |
That is what I mean. |
One need to open a pull request, follow the examples from the node-gcm package and implement the notification key inside the GCM payload. |
Okay, Just like someone did in the BTW...thank you so much for your quick responses @flovilmart and for helping me to troubleshoot this |
I believe this is a change in the google API's and we didn't catch it up. Because you caught it, that would be nice if you provide the fix too. |
Awesome! It just feels weird I am the only one seeing this issue (thought multiple people are using parse for sending push notifications). Again, thanks for everything |
The fcm branch is abandoned and should be deleted, as I thought that fcm was not compatible with the node-gcm package. You can get some inspiration from there definitely. |
@felimartina I had the same issue but I thought it was just a mis-configuration on my side |
@mmazzarolo will see if I grab some spare time these days and create a pull request...should be as simple as taking into account https://firebase.google.com/docs/cloud-messaging/http-server-ref#notification-payload-support |
Well 'GCM', is oldddd..... |
How would we go about developing a push adapter for FCM. Projects created in Google Console seem to now be required to use Firebase Cloud Messaging instead of GCM. I've tried to start an FCM adapter by copying the GCM adapter where I could but I'm changing certain parts when needed based on fcm-node documentation.
The text was updated successfully, but these errors were encountered: