-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Android doesn't receive push notifications from Parse Server #3654
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
I think your missing a few steps from this tutorial https://firebase.google.com/docs/android/setup |
Hi dafinley! Yes, when I coded my app with Parse.com Android still used GCM to send push notifications, I don't have anything related to FCM in my code. So then, I have to migrate from GCM to FCM in order to have my push notifications working again? |
I have the exact same problem - followed everything on Parse's instruction to set up Push (not using Firebase). Any hint or help is great appreciated! |
I'll know for sure when I finish tomorrow but yea everything is in FCM now and it definitely requires some changes to your Android app. iOS pretty much worked seamlessly |
Thanks for the help. However, when I did a test Push (via local-hosted dashboard), it shows "0 Push sent" for android devices (IOS devices received the test push). I'm really scratching my head here..... |
What does your index file look like? For the parse server |
This is an FCM Messaging sample Android App https://github.com/firebase/quickstart-android/tree/master/messaging/app |
var api = new ParseServer({ |
Have you tried to send a push notification from your FCM console. Its going to look something like this https://console.firebase.google.com/project/**project-id**/notification/compose |
Yes I tried sending push from Firebase console too. It also shows that "0 push sent". So the problem is somewhere in my Android app codes.... |
Did you override FirebaseMessagingService and FirebaseInstanceId? |
No, I used the default gcm settings outlined in the Parse Server wiki. |
I was able to receive the fcm push notifications from the firebase console, but I did override the FirebaseMessagingService and FirebaseInstanceId in the Android app. I would work on that part first then come back to the parse server. DDDFirebaseInstanceIdService.java
DDDFirebaseMessagingService.java
AndroidManifest.xml
|
Thank you so much for your help. It turned out, it was a really stupid mistake that I made. After I did a "git commit" and then "eb deploy" successfully pushed the new settings to aws and push went through successfully. From AWS --- "If git is installed, EB CLI uses the git archive command to create a .zip file from the contents of the most recent git commit command." |
@jenlai1345 yeah, however, if git is 'not' installed it will zip it all. Confusing AF! |
Hi! Sorry for reopen this but after following all these steps I can't send push notifications to Android. But I think I'm a bit closer. I've migrated my project from GCM to FCM. The first thing I've seen is that I cannot update Installation.deviceToken from MyFirebaseInstanceIDService:onTokenRefresh because deviceToken is read-only. It's ok. Of course, if I send a push notification now from Parse Dashboard to my device the push is not sent, I guess because the device token is not defined. So, what am I missing here? Do I need to do anything else so Parse Server creates automatically the Android device tokens? |
Can your Android device receive notifications from the Firebase console? |
Yes, I've just tested and after setting the token in the firebase console the push notification is received properly in my Android device. Could this confirm that the problem is that deviceToken is undefined in Parse Server? |
Set your VERBOSE=1 to see what the output is after you push...it should tell if your having issues.
|
I'm not sure if I'm doing this well. I've set verbose:true in my index.js file, and I've sent an iOS push (success) and an Android push (fail) but:
How should I enable and check the logs? |
If your on a linux box you can
But after you finish do
You'll see something like this on startup
|
If your Installation does not have a deviceToken I dont think the Parse Server will send it a notification |
Hi dafinley! Before your last post I've been testing android push notifications setting manually the firebase token in Installation table with Parse Dashboard, and the push notifications have been received. |
I think our posts have been send at the same time ;-). Just for summarizing: |
Honestly, I don't know. My old device installs cause Sender Id Mismatch which makes sense but they also have deviceTokens, but new installs do not have deviceTokens. So I am looking for a solution as well. |
The short term solution may be to just send an api request to the fcm console from cloud code and only use parse for sending to ios until you get to a 3rd party solution |
I'll probably test with this solution: #3099 |
All of my ios installations have the deviceToken field populated |
If there's an issue with the android SDK for registering deviceToken's probably, you should open an issue on the android SDK repo. @rogerhu what do you think? Also, you should probably not trust anyone's built SDK's but the official one's |
Hi flovimart! I've checked that iOS SDK has a specific method to update deviceToken. Maybe Android should have another one? |
What's odd is that the android SDK doesn't have a public method to set the deviceToken, whatcha means it gathers it by itself. Maybe a quick look at the source would tell you why it doesn't set it .) |
Take a look at http://guides.codepath.com/android/Push-Notifications-Setup-for-Parse. I've spent many hours dealing with validating Push config setups on Android and trying to explain it to others. I think there are more sane ways going forward but you should run through the checklist there (especially the AndroidManifest.xml file configs_ |
I've just fixed it! My problem was due to the migration process from GCM to FCM. This process sais to remove all permissions and services related to GCM from AndroidManifest.xml and add those related to FCM. |
Can you post your updated AndroidManifest |
I already had those permissions from that link. I'll just check the error logs when I get home |
This is my Android manifest:
|
I think the services are very important too in this case. |
Yep everything is important. :) http://guides.codepath.com/android/Push-Notifications-Setup-for-Parse#troubleshooting |
@rogerhu, this guide is 💯. |
No, I've created both classes with their methods but everything is empty, they have no functionality. |
Firebase console pushes are successful. So your Installation row in parse server has the deviceToken field populated or your parse server sent the push to the device? My parse server wont even try to send the push if the deviceToken field is empty |
In my case, once I re-added to my Manifest all related to GCM and once I make a new installation, the row in PArse Server is created with my device token. |
At first sight I don't see anything strange. Have you tried to init Parse with Parse.setLogLevel(Parse.LOG_LEVEL_VERBOSE); and check all logs in your android app? This was what pointed me in the right direction yesterday. |
@rferbesa That fixed the deviceToken!! This was previous developer's app and the name changed but not the package...so I had a typo in the cd2 message and the category for the GCM broadcast. Good news is that got deviceToken in there. Tricky news is now that parse can push to the device...it throws a 401 error maybe @rogerhu has seen this
|
Had to use the right API key from the Google console. That gave me a successful push...but didn't actually display the push on the device :) So definitely getting closer
|
FYI -- if you are using Gradle you can use |
Scheduled Push Successfully received from parse server...This was the last step integrating agenda with parse server. Thanks Everybody |
Hi everyone, very insightful thread here. I have a similar problem but haven't been able to solve it. I set up a new firebase project just last week, so I never used GCM at all. I am abe to successfully receive push notifications from the Firebase console to my android device. And when I send pushes from the Parse console, it says sent, but they are never actually received by the device. One diference is that I am not using the parse SDK in my android project--I am just using the Rest API. So I am manually saving user's data via a POST request to my parse backend once I receive the token from firebase. This works to save the PFInstallation. Could this be part of the problem? As far as I understand, I send pushes to mybackend/parse/push, and then parse sends them to firebase FCM, and then FCM sends them to my device. Since I can receive pushes form the FCM console, I am pretty sure the problem is not client side but rather server side. My index.js has:
Sending the push notifications form the parse console says they are successfully sent, but obviously they aren't. Any idea what other connection between the server and FCM I should be doing? I think my problem lies there but not sure what else I can do. Any help is appreciated. Thanks! |
Also, when I send pushes from Parse Push console, they do not appear in the firebase push console (which they should if FCM is sending them to the device, right?) |
I would put verbose on parse server and see the logs while the parse server attempts to send the push notifications. It will list out every device it tries from your targeting and little bit of information about what happened. You might just try to inspect the latest Android SDK for push notifications to see exactly how their api request is generated. |
@dafinley How did you able to display push on device? What changes did you make for it? |
Looks like Parse server wants deviceToken even for FCM messaging. Once you confirm you can send notification to android using Firebase console, you can use this trick to update device token. |
Hi I know this issue is closed but I'm experiencing the same thing as @dafinley, and specifically i'm in the same situation as @JoeyBodnar, as we are using RESTful Services and I can not find a solution.
It says push are sent but are not displayed in the application neither the firebase console. |
Hi!
Since I didn't have success asking this in Stackoverflow I'm trying this way.
I've migrated my Android and iOS apps from parse.com to Parse Server. After the migration, everything is working well but the push notifications to Android devices (they are working well to my iOS app).
This is what I've done so far.
1. In my Parse Server code (on Digital Ocean by the way), in /home/parse/index.js I've initialized Parse Server this way:
I’ve taken "my GCM sender ID" from my Google Developer Consoler, it’s the 12 digits number from Settings > Project number.
I’ve tried with 3 different "my GCM API Key", one without app restrictions, one available only for my android/debug.keystore and one available only for my app keystore.
I’ve checked that I have selected this app in my Google Developer console and that my package id is correct in all places.
2. In Android I’m initializing Parse this way:
3. In Android I’ve added this to my Android Manifest:
The rest of my manifest and my GCM configuration is the same I had before the migration.
4. Setting the GCMSenderId.
Some comments in Stackoverflow pointed that this could be an issue with GCMSenderId. Indeed all my Android users in Parse Server has an undefined GCMSenderId. But if I set manually this value to or even idthe push notification is not sent.
5. And as a summary.
With old parse.com push notifications worked well with Android and iOS.
With new Parse Server and the code described above iOS push notifications are working well.
With new Parse Server and the code described above Android push notifications are not being received.
With my new Parse Dashboard installed in Digital Ocean when sending push notifications both to iOS and to Android Dashboard gives a Saved! what makes me thing it’s a problem with my Android app and not with my Parse Dashboard/Parse Server configuration.
What am I missing here?
The text was updated successfully, but these errors were encountered: