Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //We build GoogleApiClient first and add AppInviteApi to it.
- GoogleApiClient client2 = new GoogleApiClient.Builder(this)
- .enableAutoManage(this, this)
- .addApi(AppInvite.API)
- .build();
- // [START get_deep_link]
- // Check if this app was launched from a deep link. Setting autoLaunchDeepLink to true
- // would automatically launch the deep link if one is found.
- //Notice we are using client2 which is a variable of the GoogleClientApi to get the invite.
- boolean autoLaunchDeepLink = true;
- AppInvite.AppInviteApi.getInvitation(client2, this, autoLaunchDeepLink)
- .setResultCallback(
- new ResultCallback<AppInviteInvitationResult>() {
- @Override
- public void onResult(@NonNull AppInviteInvitationResult result) {
- //
- //This first block of the if statement is skipped because result.getStatus().isSuccess() returns false. Which means it failed to capture the app invite
- if (result.getStatus().isSuccess()) {
- // Extract deep link from Intent
- Intent intent = result.getInvitationIntent();
- String deepLink = AppInviteReferral.getDeepLink(intent);
- //String deepLink2 =
- Log.d("invite_code", deepLink);
- Intent i = new Intent(getApplicationContext(), Referral.class);
- i.putExtra("invite_code", deepLink);
- startActivity(i);
- // Handle the deep link. For example, open the linked
- // content, or apply promotional credit to the user's
- // account.
- } else {
- //failed to get result
- Intent intent = result.getInvitationIntent();
- Log.d("firebase_invite", "getInvitation: no deep link found." + AppInviteReferral.getDeepLink(intent));
- }
- }
- });
- // [END get_deep_link]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement