microg / GmsCore

Free implementation of Play Services
https://microg.org
Apache License 2.0
8.56k stars 1.72k forks source link

GCM -> FCM Update needed for push messaging #439

Closed chris42 closed 6 years ago

chris42 commented 6 years ago

---- EDITED 26. August for summarizing the history of original issue and needed solution

Google has updated the push messaging infrastructure to FCM and will retire the old setup called GCM in 2019 (https://firebase.googleblog.com/2018/04/time-to-upgrade-from-gcm-to-fcm.html).

Hence apps are moving over to use FCM and stop working with current GCM features of microg. This results in different app behaviors. Some apps do not receive any push messages anymore, others (like Whatsapp) fall back to a polling mechanism, that uses lots of battery.

To use updated apps again with microg, the GCM functionalities mimicking google service framework will need to be updated to FCM.

---- Original Issue that lead to missing FCM functionality issue Hi there,

I have a strange behaviour on my phone with GCM on AOSP Oreo. Some apps can register for GCM, even push notification tester works flawless. However Whatsapp and Threema won't register for the service. I regularly get the message "GmsGcmRegisterSvc(6107): registration not allowed".

So far I have the feeling, that the "ask for new apps" function is not working properly. As it was enabled in the beginning (When installing Threema and Whatsapp the first time), but not anymore.

Is there a way to clear the list of registered apps and start over? This is just a hunch now and want to test this, before digging into other things.

Regards Chris

P.S.: If you have any other idea, let me know. Can also produce some logfiles.

Bountysource

chris42 commented 6 years ago

Thanks a lot for the update, I installed it and tested the following:

@mar-v-in Overall messages are on time (seems to use push). But when receiving messages, I cannot find GmsGcmMcsInput logs as in the version before. However with every message I get a GmsWearSvc GetServiceRequest for the apps (Whatsapp, Threema, DB Navigator).

Is this correct?

mar-v-in commented 6 years ago

@chris42 Threema keeps a connection open for about two minutes after closing it and in this time, messages are pushed through that connection and not through GCM. Are you sure you waited at least that time before receiving a message?

chris42 commented 6 years ago

@mar-v-in Surely was impatient. :-) But do you mean Threema or GCM overall? Just checked with Whatsapp and Threema: I get GmsGcmMcsInput after waiting a few minutes in both before receiving messages. And they are getting counted. However the ones right after that are again missing in log and count. So I assume the ones in McsInput get counted, but not the ones in existing connections?

chris42 commented 6 years ago

With all this, I would consider this issue solved. The requested functionality for the bounty is solved as well:

Registering apps in Microg with current functionality of whitelist should work again
Message counter as usual, to verify, that messaging is working
Push messages are delivered on time and reliable
Message notification is working as usual

@mar-v-in Happy if you claim the bounty. If you do not want to claim it, let me know, then I can reallocate it.

mar-v-in commented 6 years ago

I consider this issue fixed then.

@chris42 this was about Threema. "existing connection" is referring to a network connection directly between Threema App and their servers. Not all messages are routed through GCM, only those that need to, i.e. when it is not possible within the app, because the app was closed for some time (the reason for that is that GCM has some rate limiting, so it is not possible to route all chat messages through GCM in real time).

RE bounty: I am happy to claim it, just wanted to make sure that nobody feels that something important is missing.

symphorien commented 6 years ago

With a fresh install of lineageOS 14.1 for microg (0.2.5-12879) the google play version of riot is not able to register. When changing the gcm settings in the app, it tries to force register and fails. I get this toaster: https://github.com/vector-im/riot-android/blob/05b9532a29b420411d7674172608b8ae3c488fc8/vector/src/main/java/im/vector/gcm/GcmRegistrationManager.java#L609 Logcat gives:

09-29 22:53:49.484  3506  3506 D GmsGcmRegisterSvc: onBind: Intent { act=com.google.android.c2dm.intent.REGISTER pkg=com.google.android.gms }
09-29 22:53:49.502  3506  5021 D GmsHttpFormClient: -- Request --
09-29 22:53:49.502  3506  5021 D GmsHttpFormClient: X-GOOG.USER_AID=0&device=0&app=im.vector.alpha&cert=xxxxxx&app_ver=81500&sender=xxxx
09-29 22:53:49.543  3506  5021 D GmsHttpFormClient: -- Response --
09-29 22:53:49.543  3506  5021 D GmsHttpFormClient: Error=PHONE_REGISTRATION_ERROR
09-29 22:53:49.544  3506  5021 D GmsGcmRegisterSvc: received response: RegisterResponse{token='null', retryAfter='null', deleted='null'}
09-29 22:53:49.549  4829  5019 W FirebaseInstanceId: Unexpected response: Bundle[{registration_id=null}]
09-29 22:53:49.549  4829  5019 W FirebaseInstanceId: java.lang.Throwable
09-29 22:53:49.549  4829  5019 W FirebaseInstanceId:    at com.google.firebase.iid.zzq.zza(Unknown Source)
09-29 22:53:49.549  4829  5019 W FirebaseInstanceId:    at com.google.firebase.iid.zzq.zza(Unknown Source)
09-29 22:53:49.549  4829  5019 W FirebaseInstanceId:    at com.google.firebase.iid.zzt.then(Unknown Source)
09-29 22:53:49.549  4829  5019 W FirebaseInstanceId:    at com.google.android.gms.tasks.zzd.run(Unknown Source)
09-29 22:53:49.549  4829  5019 W FirebaseInstanceId:    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
09-29 22:53:49.549  4829  5019 W FirebaseInstanceId:    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
09-29 22:53:49.549  4829  5019 W FirebaseInstanceId:    at java.lang.Thread.run(Thread.java:761)
09-29 22:53:49.550  4829  4848 E FirebaseInstanceId: Token retrieval failed: SERVICE_NOT_AVAILABLE

Microg settings say 0 apps are registered with gcm. Riot does not receive call any notifications when polling is disable and the app is not in the foreground. I have no fire-walling app or so, microg self-test is all green.

chris42 commented 6 years ago

Could you please check version 0.2.6-13280 and see if you still have an issue? Then it possibly makes sense to open a specific issue for that app.

symphorien commented 6 years ago

Same result with 0.2.6.13280 even after uninstalling/reinstalling the app. I'll open a new issue.

Mafus1 commented 6 years ago

I freshly installed Lineage OS for microg 15.1 with GsmCore Version 0.2.6.13280 and i checked that:

But never the less I can't get any app to register to Google Cloud Messaging. I even checked with notification tester but it fails to "Register for Push Notification". Any idea what might cause the problems? I attached a log file. push_notification_tester_log_1.txt

EDIT: today out of the blue, everything seems to work just fine! All the apps registered correctly. Maybe it took some time for the google device registration to go through?

karcherm commented 6 years ago

I got the symptoms you described until I added a GMS Google account in the android settings. I don't remember whether I had to reboot after that for push notifications to work.

mar-v-in commented 6 years ago

There seems to be an issue with automatic device registration in latest version. If you have similar issues as described by @Mafus1, open the system phone app and dial *#*#2432546#*#* to do a manual device registration.

Mafus1 commented 6 years ago

I didn't have to add a GMS Google account like @karcherm said, but maybe this works for others. If I have the Problem again, I will try what @mar-v-in suggested.

WolfangAukang commented 5 years ago

I was in the same condition as @Mafus1 (LineageOS 15.1 with microg 0.2.6.13280, clean installation). Followed @karcherm strategy with a reboot and now GCM is connected.

Excuse any formatting issues, did this on mobile.

dschrempf commented 5 years ago

I can confirm that I had to do a manual device registration with the code provided above on LOS 14.1, official microG 13280.

wooque commented 5 years ago

I have LineageOS 15.1 with microG 0.2.6.13280 and had to dial code that @mar-v-in suggested to connect Google Cloud Messaging

NvrBst commented 5 years ago

I think there might be some minor FCM logic missing from the latest version in relation to gms checkin. I can tell using the "Push Notification Tester" app on microG's download page that v2.6 of the tester app does not work on clean installs (it does work after a device registration succeeded), but v2.5 works fine after a clean install. In the changelog it says v2.6 is when the author added FCM support.

I think microG does a checkin automatically when a GCM token is requested, I think maybe this is being skipped with FCM token requests? Else, if fcm tokens don't occur through microG, maybe make it so it'll always attempt a gcm checkin (if needed) whenever something in the gcm pipline happens (connection, registration, etc).

ale5000-git commented 5 years ago

Related to #313

ghost commented 5 years ago

This is obviously not fixed. Why was a bounty paid out and this issue closed?

chris42 commented 5 years ago

@lifranc Please read the issue thread, the comments of the backers and observe the timeline.

ale5000-git commented 5 years ago

@lifranc Most FCM apps are now working (which is what this ticket was about). For the other different or new problems you need to open a different ticket.

BurhanBudak commented 1 year ago

Hi is this thread open for discussion, as you know RCS and Jibe doesn use FCM but uses Play Services to register RCS. I kind of did activate RCS by backup up a app from a Google enabled devices and transferred the zip to a LineageOS phone. Now I have RCs enabled with MicroG but the service doesn't use FCM.

ale5000-git commented 1 year ago

@BurhanBudak This should be fixed from a lot of time; if you still have problems please update microG to the latest version and open a new ticket.