The application invites the use of Firebase does not work

Developing an application in which Firebase is used as a backend. He is currently stuck during the implementation of the Firebase App Invite. Just looking at sending invitations (currently not trying to implement a click on a dynamic link by a new user), but onActivityResult returns an invalid result_code

Steps followed

  • Integrated FireBase SDK and successful authentication.
  • Firebase enabled dynamic link and mentioned in app
  • Pressing the invitation button shows the built-in Firebase activity with the ability to select users to invite and send (SMS or Email Invites).
  • The application will return to the invitation screen as expected.

Code snippet

InviteActivity

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 RESULT_OK is -1 when debugging

New to Firebase, it would be appreciated if I indicated what I was doing wrong.

+4
source share
2 answers

After several hours of struggle, I found the problem and fixed it by posting it here, since it can be useful for others.

Initial hint: "Create invitation failed to execute error code: 3". A similar problem occurred here in SO. It was not possible to get invited invitees because of an 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 problem.

Another point worth noting, the "api_key" in google-services.json, downloaded from Firebase and Web Api Key, is not related. I tried to copy and paste the api key into the json file manually from the control panel to api_key under the wrong view, which could be the cause of the error.

+4
source
  • Sign in to Firebase Console: https://console.firebase.google.com

  • You will need to click the "Add Fingerprint" button, and then add the key to your SHA1. You need not to restart your google-services.json, you just need to add the SHA1 key.

  • Try sending an application invitation from your application. Now it will work.

firebase

+1
source

All Articles