com.google.android.gms.appinvite.AppInviteReferral Java Examples

The following examples show how to use com.google.android.gms.appinvite.AppInviteReferral. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AppInvites.java    From easygoogle with Apache License 2.0 6 votes vote down vote up
@Override
public void onStart() {
    super.onStart();

    // If app is already installed app and launched with deep link that matches
    // DeepLinkActivity filter, then the referral info will be in the intent.
    Intent launchIntent = getFragment().getActivity().getIntent();
    if (AppInviteReferral.hasReferral(launchIntent)) {
        processReferralIntent(launchIntent);
    }

    // Register the local BroadcastReceiver
    IntentFilter intentFilter = new IntentFilter(
            getFragment().getString(R.string.action_deep_link));
    LocalBroadcastManager.getInstance(getFragment().getActivity()).registerReceiver(
            mDeepLinkReceiver, intentFilter);
}
 
Example #2
Source File: MainPresenter.java    From FastAccess with GNU General Public License v3.0 5 votes vote down vote up
@Override public void onResult(@NonNull AppInviteInvitationResult result) {
    if (result.getStatus().isSuccess()) {
        Intent intent = result.getInvitationIntent();
        String deepLink = AppInviteReferral.getDeepLink(intent);
        Uri data = intent.getData();
        String userId = data.getQueryParameter(BuildConfig.SHARED_URI);
        Logger.e(deepLink, data, userId);
        if (!InputHelper.isEmpty(userId)) {
            if (isAttached()) getView().onRestoreFromUserId(userId);
        }
    } else {
        Logger.e("no deep link found.");
    }
}
 
Example #3
Source File: AppInvitesReferralReceiver.java    From easygoogle with Apache License 2.0 5 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) {
    // Create deep link intent with correct action and add play store referral information
    Intent deepLinkIntent = AppInviteReferral.addPlayStoreReferrerToIntent(intent,
            new Intent(context.getString(R.string.action_deep_link)));

    // Let any listeners know about the change
    LocalBroadcastManager.getInstance(context).sendBroadcast(deepLinkIntent);
}
 
Example #4
Source File: AppInvites.java    From easygoogle with Apache License 2.0 5 votes vote down vote up
protected AppInvites() {
    // Instantiate local BroadcastReceiver for receiving broadcasts from
    // AppInvitesReferralReceiver.
    mDeepLinkReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            // First, check if the Intent contains an AppInvite
            if (AppInviteReferral.hasReferral(intent)) {
               processReferralIntent(intent);
            }
        }
    };
}
 
Example #5
Source File: AppInvites.java    From easygoogle with Apache License 2.0 5 votes vote down vote up
private void processReferralIntent(Intent intent) {
    // Confirm receipt of the invitation
    if (getFragment().isConnected()) {
        updateInvitationStatus(intent);
    } else {
        Log.w(TAG, "GoogleAPIClient not connected, can't update invitation.");
        mCachedInvitationIntent = intent;
    }


    // Notify the listener of the received invitation
    String invitationId = AppInviteReferral.getInvitationId(intent);
    String deepLink = AppInviteReferral.getDeepLink(intent);
    getListener().onInvitationReceived(invitationId, deepLink);
}
 
Example #6
Source File: AppInvites.java    From easygoogle with Apache License 2.0 5 votes vote down vote up
private void updateInvitationStatus(Intent intent) {
    // Extract invitation Id
    String invitationId = AppInviteReferral.getInvitationId(intent);

    // Update invitation installation status and also convert the invitation.
    GoogleApiClient gac = getFragment().getGoogleApiClient();
    if (AppInviteReferral.isOpenedFromPlayStore(intent)) {
        AppInvite.AppInviteApi.updateInvitationOnInstall(gac, invitationId);
    }

    AppInvite.AppInviteApi.convertInvitation(gac, invitationId);
}
 
Example #7
Source File: MainActivity.java    From snippets-android with Apache License 2.0 4 votes vote down vote up
public void getDeepLink() {
    Intent intent = getIntent();
    // [START ddl_get_deep_link]
    String link = AppInviteReferral.getDeepLink(intent);
    // [END ddl_get_deep_link]
}