# Google.Play.Instant.InstallLauncher

Provides methods that an instant app can use to display a [Play](https://developer.android.com/reference/unity/namespace/Google/Play#namespaceGoogle_1_1Play) 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)) { https://developer.android.com/reference/unity/class/Google/Play/Instant/InstallLauncher#classGoogle_1_1Play_1_1Instant_1_1InstallLauncher_1ac65d5120106b1d3c316bb41eebade865(postInstallIntent, "payload", "test"); https://developer.android.com/reference/unity/class/Google/Play/Instant/InstallLauncher#classGoogle_1_1Play_1_1Instant_1_1InstallLauncher_1ad74c3b5bb399c3b1e50e2e418e181673(activity, requestCode, postInstallIntent, "referrer"); } `

Example code for the installed app to retrieve the result: ` string payload = https://developer.android.com/reference/unity/class/Google/Play/Instant/InstallLauncher#classGoogle_1_1Play_1_1Instant_1_1InstallLauncher_1a7de24c14a4154d0e972bc011598d6bf7("payload"); `

This is a C# implementation of the Java showInstallPrompt() method available in [Google Play Services' InstantApps class](https://developers.google.com/android/reference/com/google/android/gms/instantapps/InstantApps).

| ### Public static functions ||
|---|---|
| `https://developer.android.com/reference/unity/class/Google/Play/Instant/InstallLauncher#classGoogle_1_1Play_1_1Instant_1_1InstallLauncher_1ac251a85b14091798c46fb4a4654cad6d(AndroidJavaObject activity)` | `AndroidJavaObject` Creates an Intent for the [Play](https://developer.android.com/reference/unity/namespace/Google/Play#namespaceGoogle_1_1Play) Store to launch after installing the app. |
| `https://developer.android.com/reference/unity/class/Google/Play/Instant/InstallLauncher#classGoogle_1_1Play_1_1Instant_1_1InstallLauncher_1a7de24c14a4154d0e972bc011598d6bf7(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()](https://developer.android.com/reference/unity/class/Google/Play/Instant/InstallLauncher#classGoogle_1_1Play_1_1Instant_1_1InstallLauncher_1ad74c3b5bb399c3b1e50e2e418e181673). |
| `https://developer.android.com/reference/unity/class/Google/Play/Instant/InstallLauncher#classGoogle_1_1Play_1_1Instant_1_1InstallLauncher_1ac65d5120106b1d3c316bb41eebade865(AndroidJavaObject postInstallIntent, string extraKey, string extraValue)` | `void` This method can be called with the Intent obtained from [CreatePostInstallIntent](https://developer.android.com/reference/unity/class/Google/Play/Instant/InstallLauncher#classGoogle_1_1Play_1_1Instant_1_1InstallLauncher_1ac251a85b14091798c46fb4a4654cad6d) to add a string extra that will be passed through to the installed app. |
| `https://developer.android.com/reference/unity/class/Google/Play/Instant/InstallLauncher#classGoogle_1_1Play_1_1Instant_1_1InstallLauncher_1ad74c3b5bb399c3b1e50e2e418e181673(string referrer)` | `void` Shows a dialog that allows the user to install the current instant app. |
| `https://developer.android.com/reference/unity/class/Google/Play/Instant/InstallLauncher#classGoogle_1_1Play_1_1Instant_1_1InstallLauncher_1a1f3b63c524c8b4245d49ef2d4f5cc3c9(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

```c#
AndroidJavaObject CreatePostInstallIntent(
  AndroidJavaObject activity
)
```
Creates an Intent for the [Play](https://developer.android.com/reference/unity/namespace/Google/Play#namespaceGoogle_1_1Play) 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.

<br />

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

### GetPostInstallIntentStringExtra

```c#
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()](https://developer.android.com/reference/unity/class/Google/Play/Instant/InstallLauncher#classGoogle_1_1Play_1_1Instant_1_1InstallLauncher_1ad74c3b5bb399c3b1e50e2e418e181673).

It assumes that the current activity was the one that was launched by [Play](https://developer.android.com/reference/unity/namespace/Google/Play#namespaceGoogle_1_1Play) Store.

<br />

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

### PutPostInstallIntentStringExtra

```c#
void PutPostInstallIntentStringExtra(
  AndroidJavaObject postInstallIntent,
  string extraKey,
  string extraValue
)
```
This method can be called with the Intent obtained from [CreatePostInstallIntent](https://developer.android.com/reference/unity/class/Google/Play/Instant/InstallLauncher#classGoogle_1_1Play_1_1Instant_1_1InstallLauncher_1ac251a85b14091798c46fb4a4654cad6d) to add a string extra that will be passed through to the installed app.

<br />

Details Parameters `postInstallIntent` An Intent obtained from [CreatePostInstallIntent](https://developer.android.com/reference/unity/class/Google/Play/Instant/InstallLauncher#classGoogle_1_1Play_1_1Instant_1_1InstallLauncher_1ac251a85b14091798c46fb4a4654cad6d). `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

```c#
void ShowInstallPrompt(
  string referrer
)
```
Shows a dialog that allows the user to install the current instant app.

<br />

Details Parameters `referrer` Optional install referrer string.

### ShowInstallPrompt

```c#
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.

<br />

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](https://docs.unity3d.com/Manual/AndroidUnityPlayerActivity.html) 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.