Created
September 29, 2017 17:46
-
-
Save jirawatee/1621b42091b0eb3f338497dd03c05cbb to your computer and use it in GitHub Desktop.
Firebase Invites -
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Check for App Invite invitations and launch deep-link activity if possible. | |
// Requires that an Activity is registered in AndroidManifest.xml to handle | |
// deep-link URLs. | |
FirebaseDynamicLinks.getInstance().getDynamicLink(getIntent()) | |
.addOnSuccessListener(this, new OnSuccessListener<PendingDynamicLinkData>() { | |
@Override | |
public void onSuccess(PendingDynamicLinkData data) { | |
if (data == null) { | |
Log.d(TAG, "getInvitation: no data"); | |
return; | |
} | |
// Extract invite | |
FirebaseAppInvite invite = FirebaseAppInvite.getInvitation(data); | |
if (invite != null) { | |
String invitationId = invite.getInvitationId(); | |
Log.d(TAG, "invitationId:" + invitationId); | |
} | |
// Get and handle the deep link | |
Uri deepLink = data.getLink(); | |
if (deepLink != null) { | |
Intent intent = new Intent(Intent.ACTION_VIEW); | |
intent.setPackage(getPackageName()); | |
intent.setData(deepLink); | |
startActivity(intent); | |
} | |
} | |
}) | |
.addOnFailureListener(this, new OnFailureListener() { | |
@Override | |
public void onFailure(@NonNull Exception e) { | |
Log.w(TAG, "getDynamicLink:onFailure", e); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment