johanw666 / Signal-Android

Fork from a private messenger for Android with extra options added: full backup and (partial, ony text) xml backup of messages. Restore can happen at any time, not only after a fresh install. Import SMS database. Import of (unencrypted) WhatsApp databases. Removed apk expire. Choose between passphrase protection and the Android screenlock. Choice for the backup location (internal or removable storage on Android < 11 (on 11 and higher this is already possible)). Set the maptype in the place picker. Option to treat view-once media as normal media. Option to ignore remote deletion. Choose between FCM or websocket notification delivery.
https://johanw.home.xs4all.nl/Signal/signal-jw.html
GNU Affero General Public License v3.0
246 stars 16 forks source link

Unable to register with FCM due to mismatch API Keys #104

Closed jackfagner closed 2 weeks ago

jackfagner commented 3 weeks ago

Bug description

Signal-JW is currently unable to register with Firebase Cloud Messaging (FCM) due to upstream API keys being restricted by APK signature. Signal is pinning their FCM keys to their APK signing keys. You need to change the FCM keys in firebase_messaging.xml when compiling (signing) a Signal fork.

Steps to reproduce

Actual result: Notifications are delayed until you open the app. FCM will log "FIS_AUTH_ERROR" Expected result: Instant notifications on new messages

Device info

Device: Asus Zenfone 8 Android version: 13 Signal version: 7.9.6

johanw666 commented 3 weeks ago

I have issues on one device, it works on another but if this is the issue, can you please tell me which keys to put there? Should I just generate keys? Can I put the same key as I use for Google Maps?

jackfagner commented 3 weeks ago

According to the Signal issue https://github.com/signalapp/Signal-Android/issues/13451 "you must register your own Firebase API tokens paired to your signing key". Also note, not all of the values should be changed, only these four:

I haven't generated Firebase keys myself, so I'm not 100% sure how it's done, but I assume you login with your developer account and generate new keys. These instructions might help: https://firebase.google.com/docs/projects/api-keys

johanw666 commented 3 weeks ago

I found a solution on https://github.com/signalapp/Signal-Android/issues/13451#issuecomment-1978237171

Starting to upload a new build now, please let me know if this fixes it.

jackfagner commented 3 weeks ago

The keys seem to be changed in the APK, but still no working FCM registration. Here are some relevant lines from the debug log: fcm_log.txt

EDIT I also see this error in my logs: 06-25 23:04:19.779 20054 20115 I FcmRefreshJob: Reregistering FCM... 06-25 23:04:19.783 20054 20077 E FirebaseMessaging: Failed to get FIS auth token 06-25 23:04:19.783 20054 20077 E FirebaseMessaging: java.util.concurrent.ExecutionException: com.google.firebase.installations.FirebaseInstallationsException: Firebase Installations Service is unavailable. Please try again later. Googling that error led me here: https://support.google.com/googleplay/android-developer/thread/253824756/how-to-sign-my-app-if-recently-change-the-package-name?hl=en

johanw666 commented 2 weeks ago

Ah I forgot to change the project_id. It should work in 7.10.1.0-JW

jackfagner commented 2 weeks ago

Sorry to say, it's still not working :-/ Same error in the log file: 06-27 09:01:14.407 6320 6341 E FirebaseMessaging: Failed to get FIS auth token 06-27 09:01:14.407 6320 6341 E FirebaseMessaging: java.util.concurrent.ExecutionException: com.google.firebase.installations.FirebaseInstallationsException: Firebase Installations Service is unavailable. Please try again later. and 06-27 09:01:15.150 6320 6373 W FcmUtil : Failed to get the token. 06-27 09:01:15.150 6320 6373 W FcmUtil : java.io.IOException: java.util.concurrent.ExecutionException: java.io.IOException: FIS_AUTH_ERROR

johanw666 commented 2 weeks ago

Strange, I didn't see the error in my logs anymore since 7.10.0.2-JW (a test version with the fix I never released). I have not seen it with 7.10.1.0-JW either.

jackfagner commented 2 weeks ago

It must have been some mistake on my end. I did a fresh test just now with 7.10.1.0 and FCM seem to be working. Great job! You may close this issue.