Google.Play.Instant.InstallLauncher

Provides methods that an instant app can use to display a Play Store install dialog.

Summary

This dialog will allow the user to install the current instant app as a full app.

Example code for the instant app's install button click handler: const int requestCode = 123; using (var activity = InstallLauncher.GetCurrentActivity()) using (var postInstallIntent = InstallLauncher.CreatePostInstallIntent(activity)) { InstallLauncher.PutPostInstallIntentStringExtra(postInstallIntent, "payload", "test"); InstallLauncher.ShowInstallPrompt(activity, requestCode, postInstallIntent, "referrer"); }

Example code for the installed app to retrieve the result: string payload = InstallLauncher.GetPostInstallIntentStringExtra("payload");

This is a C# implementation of the Java showInstallPrompt() method available in Google Play Services' InstantApps class.

Public static functions

CreatePostInstallIntent(AndroidJavaObject activity)
AndroidJavaObject
Creates an Intent for the Play Store to launch after installing the app.
GetPostInstallIntentStringExtra(string extraKey)
string
This method can be called from an installed app to obtain a string that was included in the postInstallIntent provided by an instant app via ShowInstallPrompt().
PutPostInstallIntentStringExtra(AndroidJavaObject postInstallIntent, string extraKey, string extraValue)
void
This method can be called with the Intent obtained from CreatePostInstallIntent to add a string extra that will be passed through to the installed app.
ShowInstallPrompt(string referrer)
void
Shows a dialog that allows the user to install the current instant app.
ShowInstallPrompt(AndroidJavaObject activity, int requestCode, AndroidJavaObject postInstallIntent, string referrer)
void
Shows a dialog that allows the user to install the current instant app.

Public static functions

CreatePostInstallIntent

AndroidJavaObject CreatePostInstallIntent(
  AndroidJavaObject activity
)

Creates an Intent for the Play Store to launch after installing the app.

It will launch the specified activity. This Intent can be extended to contain additional extras for passing to the installed app. This object should be disposed after use.

Details
Returns
A wrapped Intent object. The AndroidJavaObject should be disposed.

GetPostInstallIntentStringExtra

string GetPostInstallIntentStringExtra(
  string extraKey
)

This method can be called from an installed app to obtain a string that was included in the postInstallIntent provided by an instant app via ShowInstallPrompt().

It assumes that the current activity was the one that was launched by Play Store.

Details
Parameters
extraKey
Key for obtaining a string extra from current activity's intent.
Returns
The string extra value.

PutPostInstallIntentStringExtra

void PutPostInstallIntentStringExtra(
  AndroidJavaObject postInstallIntent,
  string extraKey,
  string extraValue
)

This method can be called with the Intent obtained from CreatePostInstallIntent to add a string extra that will be passed through to the installed app.

Details
Parameters
postInstallIntent
An Intent obtained from CreatePostInstallIntent.
extraKey
Key for a string extra to add to the post install intent.
extraValue
Value for a string extra to add to the post install intent.

ShowInstallPrompt

void ShowInstallPrompt(
  string referrer
)

Shows a dialog that allows the user to install the current instant app.

Details
Parameters
referrer
Optional install referrer string.

ShowInstallPrompt

void ShowInstallPrompt(
  AndroidJavaObject activity,
  int requestCode,
  AndroidJavaObject postInstallIntent,
  string referrer
)

Shows a dialog that allows the user to install the current instant app.

This method is a no-op if the current running process is an installed app. A post-install intent must be provided, which will be used to start the application after install is complete.

Details
Parameters
activity
The activity that should launch the store's install dialog.
requestCode
The requestCode referenced in the onActivityResult() callback to the activity. Extend UnityPlayerActivity and check for the specified requestCode integer to know whether the dialog was cancelled. Use UnityPlayer.UnitySendMessage() to relay the response from Java back to Unity scripts.
postInstallIntent
The intent to launch after the instant app has been installed. Must resolve to an activity in the installed app package, or it will not be used.
referrer
Optional install referrer string.
Exceptions
ArgumentNullException
If either activity or postInstallIntent are null.