Developing an App which has Firebase as backend. Currently, was stuck while implementing Firebase App Invite . Just looking to send invites ( not currently trying to implement the clicking of the dynamic link by the installed new user) but the onActivityResult returns wrong result_code
Steps followed
btnInvite.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new AppInviteInvitation.IntentBuilder(INVITATION_TITLE)
.setMessage(INVITATION_MESSAGE)
.setDeepLink(Uri.parse("https://ewyc6.app.goo.gl/eNh4"))
.setCallToActionText(INVITATION_CALL_TO_ACTION)
.build();
startActivityForResult(intent, REQUEST_INVITE);
}
});
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Log.d(TAG, "onActivityResult: requestCode=" + requestCode + ", resultCode=" + resultCode + "result_ok ="+RESULT_OK);
if (requestCode == REQUEST_INVITE) {
if (resultCode == RESULT_OK) {
// You successfully sent the invite,
// we can dismiss the button.
btnInvite.setVisibility(View.GONE);
String[] ids = AppInviteInvitation.getInvitationIds(resultCode, data);
StringBuilder sb = new StringBuilder();
sb.append("Sent ").append(Integer.toString(ids.length)).append(" invitations: ");
for (String id : ids) sb.append("[").append(id).append("]");
Toast.makeText(getApplicationContext(),"Invited!!!",Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(getApplicationContext(),"Sorry, unable to send invite.",Toast.LENGTH_SHORT).show();
}
}
}
//result_code is 3 and the RESULT_OK is -1 on debugging
New to Firebase stuff , would appreciate if point out what I m doing wrong.
After hours of struggle found the issue and fixed it, posting it here since it might be helpful to others too.
The initial hint was "Create invitations failed to error code: 3" Had a similar issue here in SO Get suggested invitees failed due to error code: 3
But in my case the SHA1 certificate was already added, but the package name in Firebase turned out to be a case sensitive issue.
One more point worth taking note of, "api_key" in google-services.json downloaded from Firebase and Web Api Key are not related. I tried to copy and paste the web api key to the json file manually from dashboard to api_key under the misconception that might be the issue lead to the error.
Log onto Firebase Console: https://console.firebase.google.com
You will need to click on the "Add Fingerprint" button and then add on your SHA1 key. You do not need to redownload your google-services.json, you just need to add the SHA1 key.
Try sending an app invite from your app. It will now work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With