public interface

# AppInviteApi

com.google.android.gms.appinvite.AppInviteApi

## Class Overview

The main entry point for interacting with AppInvite invitations. This class provides a method to update invitation status after receiving an invitation id after app installation.

## Summary

Public Methods
abstract PendingResult<Status> | convertInvitation(GoogleApiClient client, String invitationId) Update the invitation to indicate that the user has taken a key "conversion" action in your app.
abstract PendingResult<AppInviteInvitationResult> | getInvitation(GoogleApiClient client, Activity currentActivity, boolean launchDeepLink) Get the invitation and optionally use the invitation deep link to launch an activity.
abstract PendingResult<Status> | updateInvitationOnInstall(GoogleApiClient client, String invitationId) This method is deprecated. Use `getInvitation(GoogleApiClient, Activity, boolean)` to access AppInvite referrer data rather than implementing a Play Store broadcast receiver.

## Public Methods

#### public abstract PendingResult<Status> convertInvitation (GoogleApiClient client, String invitationId)

Update the invitation to indicate that the user has taken a key "conversion" action in your app. It is up to you to decide what constitutes a user conversion. Common conversion events include a user completing registration, accepting an offer, or sharing an item. Required API: `API`

##### Parameters

client | The `GoogleApiClient` to service the call.
invitationId | Invitation id received from the play store.

##### Returns

- The pending result that indicates if the update succeeded.

#### public abstract PendingResult<AppInviteInvitationResult> getInvitation (GoogleApiClient client, Activity currentActivity, boolean launchDeepLink)

Get the invitation and optionally use the invitation deep link to launch an activity.

This method should be called in any activity that may be launched from an invitation, either the main activity or for already installed apps any activity with an intent filter matching the deep link.

When the user accepts an invitation and installs the app, `getInvitation(GoogleApiClient, Activity, boolean)` will update the invitation state to installed and return the invitation data in an intent accessed from `AppInviteInvitationResult` using `getInvitationIntent()`. This intent includes the invitation id and a deep link if set when creating the invitation. If launchDeepLink is true, the app is also be re-launched using the deep link, possibly launching into a different activity if there is an intent filter that matches the deep link. If launchDeepLink is false, the returned intent from `getInvitationIntent()` can alternatively be used to launch the deep link activity when appropriate for the app. Use `startActivity(Intent)` where the intent supplied is from `getInvitationIntent()`. Any activity launched while the app is already running should set its launch mode appropriate for the application.

If the app was already installed then `AppInviteInvitationResult` would also include the invitation data. The activity provided as currentActivity must be the first activity started when the app was launched since it includes the current launch intent. Installed apps will not be re-launched even if launchDeepLink is true since the app would have been initially launched using the deep link.

Alternatively, for already installed apps only, the intent returned from `getIntent()` in the launched activity already has the invitation data. If `hasReferral(Intent)` returns true, then the app is already installed and the invitation data can be accessed directly from this intent without calling `getInvitation(GoogleApiClient, Activity, boolean)`.

##### Parameters

client | Connected GoogleApiClient built with AppInvite `API`.
currentActivity | The activity launched in the currently running app.
launchDeepLink | If true, launch the app with the deep link set as the data of the launch intent if initial install.

##### Returns

- PendingResult with the invitation data delivered when the result is complete. See `AppInviteInvitationResult`.

#### public abstract PendingResult<Status> updateInvitationOnInstall (GoogleApiClient client, String invitationId)

This method is deprecated.
Use `getInvitation(GoogleApiClient, Activity, boolean)` to access AppInvite referrer data rather than implementing a Play Store broadcast receiver.

Update an invitation to indicate that your application has been installed after the user accepted the invitation. Your app will receive the invitation id via a broadcast receiver implemented by you. Learn more about processing the broadcast in `AppInviteReferral` and see sample application for an example of how to implement the broadcast receiver.

Required API: `API`

##### Parameters

client | The `GoogleApiClient` to service the call.
invitationId | Invitation id received from the play store.

##### Returns

- The pending result that indicates if the update succeeded.