Advertisement
stevekamau

Untitled

Jan 21st, 2017
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.37 KB | None | 0 0
  1. //We build GoogleApiClient first and add AppInviteApi to it.
  2.  
  3. GoogleApiClient client2 = new GoogleApiClient.Builder(this)
  4.                 .enableAutoManage(this, this)
  5.                 .addApi(AppInvite.API)
  6.                 .build();
  7.  
  8. // [START get_deep_link]
  9.         // Check if this app was launched from a deep link. Setting autoLaunchDeepLink to true
  10.         // would automatically launch the deep link if one is found.
  11. //Notice we are using client2 which is a variable of the GoogleClientApi to get the invite.
  12.  
  13.         boolean autoLaunchDeepLink = true;
  14.         AppInvite.AppInviteApi.getInvitation(client2, this, autoLaunchDeepLink)
  15.                 .setResultCallback(
  16.                         new ResultCallback<AppInviteInvitationResult>() {
  17.                             @Override
  18.                             public void onResult(@NonNull AppInviteInvitationResult result) {
  19.  
  20. //
  21. //This first block of the if statement  is skipped because result.getStatus().isSuccess() returns false. Which means it failed to capture the app invite
  22.                                 if (result.getStatus().isSuccess()) {
  23.                                     // Extract deep link from Intent
  24.                                     Intent intent = result.getInvitationIntent();
  25.                                     String deepLink = AppInviteReferral.getDeepLink(intent);
  26.                                     //String deepLink2 =
  27.  
  28.                                     Log.d("invite_code", deepLink);
  29.  
  30.                                     Intent i = new Intent(getApplicationContext(), Referral.class);
  31.                                     i.putExtra("invite_code", deepLink);
  32.                                     startActivity(i);
  33.                                     // Handle the deep link. For example, open the linked
  34.                                     // content, or apply promotional credit to the user's
  35.                                     // account.
  36.                                 } else {
  37.                                     //failed to get result
  38.                                     Intent intent = result.getInvitationIntent();
  39.                                     Log.d("firebase_invite", "getInvitation: no deep link found." +         AppInviteReferral.getDeepLink(intent));
  40.                                 }
  41.                             }
  42.                         });
  43.         // [END get_deep_link]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement