I am trying to implement an App Invite system in my Android app with Firebase. The code is exactly as that given in their guide.
private void onInviteClicked() {
Intent intent = new AppInviteInvitation.IntentBuilder("Title here")
.setMessage("message here")
.setDeepLink(Uri.parse("deep_link_here")
.setCallToActionText("Install!"))
.build();
startActivityForResult(intent, REQUEST_INVITE);
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Log.d(TAG, "onActivityResult: requestCode=" + requestCode + ", resultCode=" + resultCode);
if (requestCode == REQUEST_INVITE) {
if (resultCode == RESULT_OK) {
// Get the invitation IDs of all sent messages
String[] ids = AppInviteInvitation.getInvitationIds(resultCode, data);
for (String id : ids) {
Log.d(TAG, "onActivityResult: sent invitation " + id);
}
} else {
// Sending failed or it was canceled, show failure message to the user
// ...
Toast.makeText(getContext(), "Invite not sent!", Toast.LENGTH_SHORT).show();
}
}
}
My problem is:
- I can select emails amongst my contacts and it sends email invitations to them. However, it still returns
resultCode
0 andids
is null. - When I select a phone number from the list of contacts displayed, the fragment/activity force closes and again
resultCode
is 0.