I'm trying to migrate from C2DM to GCM, and it mostly works just fine. C2DM used to handle uninstalls of the app very well by sending a NotRegistered error when the user uninstalled the app. GCM supposedly does this as well (albeit not guaranteed). However, it doesn't seem to be working. After sending multiple GCM notifications to a phone which has uninstalled the app, it still keeps responding with a normal "id=..." response.
Has anyone else come across this problem? If so, how did you solve it?
There's really nothing we can do about it. Only Google knows when an app is uninstalled and update their device registration database accordingly. Perhaps it takes a couple of hours for NotRegistered response to come back? If after a day, you're still not getting that, then file a bug report with them: http://code.google.com/p/android/issues/list
I can't imagine Google will let this bug stay for too long, as they are potentially looking at sending phantom notifications to thousands or hundred thousands of devices.
I've been migrating from C2DM to GCM, and I thought I was having this problem as well. Long story short, try uninstalling the app from your phone/emulator, then dont reinstall it on that phone/emulator and leave the phone/emulator running for a few hours, then you should get the NotRegistered error if you try to push to that device's registration id.
If I recall correctly even if you reinstalled the app in C2DM after uninstalling you'd get the NotRegistered error for the first registration id, this is not the case with GCM (usually if not always the two registration id's will be the same) and I spent a week thinking GCM had some bug where it wasn't sending that error...
Related
I run an Android app that has users that wish to stay registered for push notifications indefinitely, and many use the app for years. I switched over my push notifications to Firebase last spring, and I'm now getting a significant number of users complaining who, after receiving notifications for months without issue, no longer receive notifications (when I try to send to the tokens I have in my database for them, I get either a InvalidRegistration or NotRegistered, not sure which tbh).
Is anyone else having this issue, and is it an issue with Firebase FCM itself? Perhaps onTokenRefresh isn't being called when it should be at times or something? (I'm certain that my code to give a refreshed token to the server is solid - I had no problems for years with the old GCM, although I had to have a bunch of hacks to re-register periodically in addition to when the user updated the app or the OS)
I see that FirebaseInstanceId.getInstance().getToken() can throw an IOException, perhaps that is killing my onTokenRefresh method before it can start sending the token to the server? Do robust apps take this possibility into account and have a mechanism to retry on failure?
Basically, just looking into any insight into why this is happening, if others are having the same issue, and any workarounds people have found. At the end of my rope over here:/
I have several apps on Google Play that extensively use GCM and they have all been working very well for quite some time now. But, all of a sudden (Aug 12, 2015), GCM is sometimes returning "NotRegistered" when my server posts a message to it.
This is happening just occasionally but that is often enough to cause big problems as the messaging can no longer be trusted.
The last part of the web response stream is: [{"error":"NotRegistered"}]}
I log the registration id along with the response stream and the registration id that I attempted to use is the same one that has always been used for that phone. My apps get a new registration id when they are first ran so it is necessary for the application to be uninstalled and reinstalled to make the app work again. Has something changed?
Oddly, (or not) the problem has only occurred on phones running 5.1 lollipop. Did I possibly miss another breaking change?
Thanks,
Dean
If you are using GoogleCloudMessaging to register, one possibility is that these users received an upgrade of your app. See the latest edit to Eran's answer here.They will need to re-register with GCM. Consider using the latest registration method using Instance IDs, which has a listener for token refresh when needed.
Working on a Google Cloud Messaging-enabled App for a class. I had "round-trip" (App->backend server, backend server->GCM->App) working on both my phone and tablet. After getting things stable, I uninstalled the App on the phone (mainly to trash the database that I'd filled with bogus entries) and then re-installed. However now, when the app attempts to re-register with GoogleCloudMessaging, it kicks back "SERVICE_NOT_AVAILABLE." I had run into this a couple days ago, but it seems like after waiting a couple of minutes, it'd be able to register. I figured it was something on Google's end needing to update. However I've let my phone sit for almost 12 hours now and it still is unable to get a new registration ID.
Is there something more required to get a new registration ID than a call to register()? I've tried calling unregister() as well, thinking that maybe GCM needed a "hint" that the phone needed a new registration ID and that the old one was invalid, but that also kicked back SERVICE_NOT_AVAILABLE. As a side note, the tablet (which has a registration ID) continues to work fine. Messages are being received from GCM. I just get nothing on the phone.
Other info: This is using the HTTP (downstream only) GCM configuration, Phone is API 17, Tablet is API 19. Play services are up-to-date. The implementation I used for the receiver and registration is "pretty close" to what Google provided as their example.
I am using Uniqush to send GCM messages to an app I'm developing, and so far this is working well. However, for obvious reasons I am uninstalling and reinstalling the app as I develop, and it's re-registering for GCM with each new install.
I understand GCM is supposed to handle this automatically:
http://developer.android.com/guide/google/gcm/adv.html#unreg
if a message can't be delivered to a device, it sends an error to the server, which handles it. Unfortunately (even after sending a test push message while the app wasn't installed) I am getting duplicate messages to my device.
Is this a failure in Uniqush, my program, GCM, or some combination of the three?
If notifications are sent to a device while it has the app uninstalled, eventually the duplicates clear.
Given your description, I am unable to reproduce your situation. Here are the steps to try to reproduce it:
Install the test app on my phone and push notification to it using uniqush. Correct. Uniqush's log shows it is successfully delivered and my phone shows the correct result.
Uninstall the test app.
push another notification again using uniqush. Uniqush's log shows the message saying the user is unsubscribed the service: [Unsubscribe][Info] 2012/12/21 19:18:08 [UnsubscribeRequest] RequestId=3992a14e4987e94e3ce16bb7394ee06d2d9e7231 Success
DeliveryPoint=gcm:47e6551857be173b1418e56b63dbdb8cd58c94a2
Then push one more notification to the device, uniqush says it cannot find the device (because it has already been removed.)
Check the database using redis-cli, the device's information is no longer stored. It is successfully unsubscribed.
However, I did found some problem: if you check the error message returned from uniqush from HTTP, then you will see Success on the second notification. I have already fixed this bug in next release. It will be online soon. (If you are interested in that, check the .deb package )
In fact, uniqush is designed to be able to handle such situation so that the user don't need to care about unsubscription, device token/registration id update, etc.
If you have any future question, please feel free to comment or contact me.
So I have a strange problem, my app has C2DM setup and and it works for the most part, however there is quite a few people who never get registered. So the flow is as follows. On login, we make the registration request, when we get the response on that it submits the registration id to my back-end server and stores it in the database. For some reason I can see that some people logged in just fine, but I never received the registration id on the server, any ideas? I haven't be able to reproduce this my self, but it is affecting a lot of people using my app. Any suggestions on how I can make this more reliable? Because when the C2DM does not work they tend to not stay and use my application.
Any help or advice would be much appreciated.
What do you do on the client side if the registration fails? It could fail for a number of reasons. It'd probably be a good idea to send the status to your backend in failure cases so you can track that. Personally, The most common failures I see are due to not having a logged in google account or having background data turned off in settings.
Could the users in question be on unsupported (pre 2.2) devices?
C2DM in intended for android devices running Android 2.2(API 8) or higher that also have the Market application installed. However, you are not limited to deploying your applications through Market.
Also make sure you make the C2DM registration at very beginning of app start say splash screen. As the C2DM to register and obtain the REG_ID take about 3-4 sec depending upon the network connection.
Also make sure the devices that it is having problem that you reported might be showing the ACCOUNT MISSING:: OR ERROR IN REG_ID when C2DM registration works