Closed thailey01 closed 7 years ago
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": { "senderId": "FCM senderId", "apiKey": "FCM server API key" },
Those are the same I use, found from the firebase console settings page. Be sure you have added the meta tag in your manifest to set the gcm key just as you normally would. That was my problem.
On Sep 13, 2016 5:34 PM, "kiis" notifications@github.com wrote:
What values do you use in parse-server config file ?
I have these fields and it seems not to work with default adapter.
{"android": { "senderId": "FCM senderId", "apiKey": "FCM server API key" },
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/parse-server-modules/parse-server-push-adapter/issues/32#issuecomment-246847537, or mute the thread https://github.com/notifications/unsubscribe-auth/AFkyEhjynFy2rMC7BBWtrMlBrTZtk25Uks5qpyUIgaJpZM4J0i1o .
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: {android: { senderId: "FCM senderId", apiKey: "FCM server API key" },
Manifest: http://pastebin.com/FAcCrAkC Server config: http://pastebin.com/j3VmTBJ2
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!
Is there any way to use FCM in parse-server-push-adapter
for sending notifications on both android and iOS devices?
I'm still trying to grok the concept, but from my understanding it should be possible to use parse-server
for sending a push through FCM independently from the device type, am I right?
Thanks guys :)
edit: I just tried using the master branch.
It works fine on Android, but not on iOS. Setting the pushType
to android
on an iOS device redirect correctly to the GCM and I get a successful response:
verb parse-server-push-adapter GCM GCM Response: {
verb parse-server-push-adapter GCM "multicast_id": 6094255852378874000,
verb parse-server-push-adapter GCM "success": 2,
verb parse-server-push-adapter GCM "failure": 0,
verb parse-server-push-adapter GCM "canonical_ids": 0,
verb parse-server-push-adapter GCM "results": [
verb parse-server-push-adapter GCM {
verb parse-server-push-adapter GCM "message_id": "0:1477468345295055%99573f33f9fd7ecd"
verb parse-server-push-adapter GCM },
verb parse-server-push-adapter GCM {
verb parse-server-push-adapter GCM "message_id": "0:1477468345198750%99573f33f9fd7ecd"
verb parse-server-push-adapter GCM }
verb parse-server-push-adapter GCM ]
verb parse-server-push-adapter GCM }
Still, on the device I don't receive any notification (sending the push through the firebase console works though).
I'd like to help on this feature but as I already said I have no experience on push notifications... do you have any suggestions?
@flovilmart @thailey01 @jeffjen
Thank you guys, let me know if I can help in any way :)
We are creating an application using parse-server
.
We created a firebase account in order to send push notifications to our android devices. However, everytime we send a Push Notification to an Android device the device does not display the notification. It does arrive, though. The Android dev states that the notification is missing the notification
field which Android uses in order to SHOW the notification in the screen.
Are we missing anything? Again, notification arrive and can be handled, however, it is not automatically shown by Android on the screen.
This is the body of the notification we are sending:
{
"where" : {
"user" : {
"__type" : "Pointer",
"className" : "_User",
"objectId" : "RKGGWkXaIh"
}
},
"data" : {
"body" : "great match!",
"title" : "Portugal vs. Denmark"
}
}
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 notification
field is. I checked the fcm-adapter
branch in this repo (the only open branch other than master
) and that one seems to have an FCM adapter which DOES TAKE INTO ACCOUNT notification
field. I believe I should be able to request a notification with the following body and would work using the fcm-adapter
branch.
{
"where" : {
"user" : {
"__type" : "Pointer",
"className" : "_User",
"objectId" : "RKGGWkXaIh"
}
},
"data" : {
"body" : "great match!",
"title" : "Portugal vs. Denmark",
"notification":{
"body" : "great match!",
"title" : "Portugal vs. Denmark"
}
}
}
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. Do you want to make a pull request to support that?
But without notification
field nothing is displayed on the Android device. What's the point of having notifications working but not having them displayed on the screen?
I pulled and compiled fcm-adapter
branch and seems to be working fine if you set the device's pushType equal to fcm
(also need to add fcm
to parse push notifications). Not sure how stable the fcm-adapter
branch is though.
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 master
branch, what do I need to change on the Android App (or in my server when requesting a push notification) in order to get Push Notifications DISPLAYED on the phone screen?
This is how I am requesting the push notification and it is not being displayed on the Android screen. Am I missing something?:
curl -X POST \
-H "X-Parse-Application-Id: ${APPLICATION_ID}" \
-H "X-Parse-REST-API-Key: ${REST_API_KEY}" \
-H "Content-Type: application/json" \
-d '{
"where" : {
"user" : {
"__type" : "Pointer",
"className" : "_User",
"objectId" : "RKGGWkXaIh"
}
},
"data" : {
"body" : "great match!",
"title" : "Portugal vs. Denmark",
"alert": "something to say"
}
}' \
http://localhost:4040/parse/push
FYI...I am using parse-server-push-adapter
from npm (1.1.0). Is that the very same version that holds the master
branch?
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. Let me re-phrase. How do I do in order to DISPLAY a notification on an Android phone?
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 fcm-adapter
. The thing is that there is no such feature in parse then, correct? There is no way, currently, to display android notifications in the phone screen using parse-server
.
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).
I will try to put something together to overcome this problem. But I am only seeing this problem when using fcm
setttigs and the gcm
sender from parse.
I will try to create a pull request (need to catch up on the repo rules first)...
I see the fcm-adapter
is doing kind of the same here. Any other thought on your side @flovilmart ?
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.
thought multiple people are using parse for sending push notifications
@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 notification
field when sending the GCM in the GCM.js
file. Let me know if you are experiencing some other issue we can see if we can add support for other options that can be sent to Android phones.
These are the fields supported in the gmc
/fmc
payload:
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.