Clive Sargeant
Clive Sargeant

Reputation: 652

Firebase Invites "message failed to send"

i have set up and successfully used Firebase dynamic links in my app. i am now trying to include Firebase Invites in the same app. i have followed the setup guide here Firebase Invites setup guide. it works as far as displaying the chooser where i select an email address (or cell number for sms), but when i press send a red snackbar appears with the message, "message failed to send" and the onActivityResult() method returns a resultCode of 3.

i have looked at all similar problems on stackoverflow but have not been able to fix the problem.

i did have a problem with the SHA-1 when setting up dynamic links in the app see my stackoverflow question here but that was resolved and the dynamic links work perfectly.

i'd appreciate any help in getting the Invites to work.thanks.

Upvotes: 1

Views: 992

Answers (3)

James Ehly
James Ehly

Reputation: 11

For anyone else having this issue, SHA-1 keys are required fro certain google play services. Invites is one of those services that requires a key. This really isn't stated anywhere directly in the app invites documentation that I could find, but it is pretty clear in the link that follows. The text below is taken from : https://developers.google.com/android/guides/client-auth

Certain Google Play services (such as Google Sign-in and App Invites) require you to provide the SHA-1 of your signing certificate so we can create an OAuth2 client and API key for your app. To get your SHA-1, follow these instructions:

Open a terminal and run the keytool utility provided with Java to get the SHA-1 fingerprint of the certificate. You should get both the release and debug certificate fingerprints.

To get the release certificate fingerprint:

keytool -exportcert -list -v \
-alias <your-key-name> -keystore <path-to-production-keystore>

To get the debug certificate fingerprint:

keytool -exportcert -list -v \
-alias androiddebugkey -keystore %USERPROFILE%\.android\debug.keystore

The keytool utility prompts you to enter a password for the keystore. The default password for the debug keystore is android. The keytool then prints the fingerprint to the terminal

Upvotes: 1

m0r6aN
m0r6aN

Reputation: 908

I realize this is old, but I'm having the same problem. Funny thing is that I was getting Error 3, Could not send 7 days ago. I "fixed" it by generating new SHA1 and SHA256 fingerprints, replacing the ones in Firebase, and utilizing the lastest google-services.json file.

I was able to send invitations up until yesterday when it suddenly started returning error 3 again. Now, 3 sets of key and 2 handfuls of hair later, it's still not working. I have an Alpha release in the play store; it's using the same apk my devices are running. I'm at a loss, I even rolled my local repository back to commit I made on the day it worked. Nadda....

Upvotes: 1

Clive Sargeant
Clive Sargeant

Reputation: 652

solved the problem. it was all about the SHA-1.

originally i generated a signed apk for the debug version. i then extracted the SHA-1 for this version using the keytool and added it to the app in the firebase console. my dynamic links worked fine under this scenario but invites would not, resulting in the "message failed to send" error.

looking at similar issues on stackoverflow i noticed that the SHA may be the problem. some suggested to include both the debug and the release SHA-1 in the firebase console. so i generated a signed release apk and extracted the SHA-1, only to realise that it is the same as the debug SHA-1.

i then tried another method of extracting the SHA-1 from the debug version. 1) (in Android Studio) i opened the Gradle projects screen (right sidebar), 2) then in the gradle project window, i selected my app>Tasks>android>signingReport (double-clicking signingReport runs and the SHA-1 is displayed in the Run window at the bottom of the screen). i noticed that this SHA-1 differs from the SHA-1 that i got from the signed debug apk.

i then added this SHA-1 fingerprint to the app in the firebase console (so i now had this debug SHA-1 and the release apk SHA-1 added to the app in the firebase console). invites now works!

Upvotes: 2

Related Questions