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

The following examples show how to use com.google.android.gms.appinvite.AppInviteInvitation. 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: MainActivity.java    From snippets-android with Apache License 2.0 6 votes vote down vote up
@Override
protected 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
            // [START_EXCLUDE]
            showMessage(getString(R.string.send_failed));
            // [END_EXCLUDE]
        }
    }
}
 
Example #2
Source File: AuthActivity.java    From Melophile with Apache License 2.0 5 votes vote down vote up
@OnClick(R.id.invite)
public void invite() {
  Intent intent = new AppInviteInvitation.IntentBuilder(getString(R.string.invitation_title))
          .setMessage(getString(R.string.invite_message))
          .setDeepLink(Uri.parse("/link"))
          .build();
  startActivityForResult(intent, 1);
}
 
Example #3
Source File: MainActivity.java    From snippets-android with Apache License 2.0 5 votes vote down vote up
/**
 * User has clicked the 'Invite' button, launch the invitation UI with the proper
 * title, message, and deep link
 */
// [START on_invite_clicked]
private void onInviteClicked() {
    Intent intent = new AppInviteInvitation.IntentBuilder(getString(R.string.invitation_title))
            .setMessage(getString(R.string.invitation_message))
            .setDeepLink(Uri.parse(getString(R.string.invitation_deep_link)))
            .setCustomImage(Uri.parse(getString(R.string.invitation_custom_image)))
            .setCallToActionText(getString(R.string.invitation_cta))
            .build();
    startActivityForResult(intent, REQUEST_INVITE);
}
 
Example #4
Source File: MainActivity.java    From snippets-android with Apache License 2.0 5 votes vote down vote up
public void sendInvitationIOS() {
    // [START invites_send_invitation_ios]
    Intent intent = new AppInviteInvitation.IntentBuilder(getString(R.string.invitation_title))
            // ...
            .setOtherPlatformsTargetApplication(
                    AppInviteInvitation.IntentBuilder.PlatformMode.PROJECT_PLATFORM_IOS,
                    IOS_APP_CLIENT_ID)
            // ...
            .build();
    // [END invites_send_invitation_ios]
}
 
Example #5
Source File: NewsActivity.java    From yahnac with Apache License 2.0 5 votes vote down vote up
private void onInviteClicked() {
    Inject.usageAnalytics().trackEvent(getString(R.string.analytics_event_app_invite_started));
    Intent intent = new AppInviteInvitation.IntentBuilder(getString(R.string.invitation_title))
            .setMessage(getString(R.string.invitation_message))
            .setCustomImage(Uri.parse(getString(R.string.invitation_custom_image)))
            .setCallToActionText(getString(R.string.invitation_cta))
            .build();
    startActivityForResult(intent, REQUEST_INVITE);
}
 
Example #6
Source File: SettingsActivity.java    From yahnac with Apache License 2.0 5 votes vote down vote up
private void onInviteClicked() {
    Inject.usageAnalytics().trackEvent(getString(R.string.analytics_event_app_invite_started));
    Intent intent = new AppInviteInvitation.IntentBuilder(getString(R.string.invitation_title))
            .setMessage(getString(R.string.invitation_message))
            .setCustomImage(Uri.parse(getString(R.string.invitation_custom_image)))
            .setCallToActionText(getString(R.string.invitation_cta))
            .build();
    startActivityForResult(intent, REQUEST_INVITE);
}
 
Example #7
Source File: AppInvites.java    From easygoogle with Apache License 2.0 5 votes vote down vote up
@Override
public boolean handleActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == RC_INVITE) {
        if (resultCode == Activity.RESULT_OK) {
            String[] ids = AppInviteInvitation.getInvitationIds(resultCode, data);
            getListener().onInvitationsSent(ids);
        } else {
            getListener().onInvitationsFailed();
        }

        return true;
    }
    return false;
}
 
Example #8
Source File: ChatPresenter.java    From eternity with Apache License 2.0 4 votes vote down vote up
Intent getInviteIntent() {
  return new AppInviteInvitation.IntentBuilder(resolver.get(R.string.invitation_title))
      .setMessage(resolver.get(R.string.invitation_message))
      .setCallToActionText(resolver.get(R.string.invitation_cta))
      .build();
}
 
Example #9
Source File: AppInvites.java    From easygoogle with Apache License 2.0 3 votes vote down vote up
/**
 * Launch the UI where the user can choose contacts and send invitations. The UI will be
 * populated with the arguments of this method, however the user can choose to change the
 * final invitation message. Success or failure of this call will be reported to
 * {@link pub.devrel.easygoogle.gac.AppInvites.AppInviteListener}.
 * @param title the title to display at the top of the invitation window. Cannot be
 *              overridden by the user.
 * @param message the message to suggest as the body of the invitation, this will be editable
 *                by the sending user.
 * @param deeplink a URI containing any information the receiving party will need to make use
 *                 of the invitation, such as a coupon code or another identifier.
 */
public void sendInvitation(String title, String message, Uri deeplink) {
    Intent intent = new AppInviteInvitation.IntentBuilder(title)
            .setMessage(message)
            .setDeepLink(deeplink)
            .build();

    getFragment().startActivityForResult(intent, RC_INVITE);
}