# In App Update

{% hint style="info" %}
You'll need to import the javascript file in your website before starting from this [link](https://docs.webtonative.com/javascript-apis/getting-started).
{% endhint %}

{% tabs %}
{% tab title="Plain Javascript" %}

```
const { InAppUpdate } = window.WTN;

InAppUpdate.checkIfAppUpdateAvailable({
    callback: function(data) {
        //your logic
    }
});

InAppUpdate.updateApplication({
    updateType: "immediate", //immediate or flexible
    callback: function(data) {
        
    }
});
```

{% endtab %}

{% tab title="ES5+" %}

```
import { InAppUpdate } from "webtonative";

InAppUpdate.checkIfAppUpdateAvailable({
    callback: function(data) {
        //your logic
    }
});

InAppUpdate.updateApplication({
    updateType: "immediate", //immediate or flexible
    callback: function(data) {
        
    }
});
```

{% endtab %}
{% endtabs %}

In `checkIfAppUpdateAvailable` it will return two keys isUpdateAvailable (boolean) and latestVersion (string)

For Example:- `{ "isUpdateAvailable": true, "latestVersion": "2.0.1" }`&#x20;

In `updateApplication`  it will return a key updateStatus (string)\
Values:- UPDATE\_CANCELLED or UPDATE\_STARTED

For Example:- `{"updateStatus":"UPDATE_CANCELLED"}`&#x20;

\*Feature added in Android on 02/07/25

### Check If App Update Available

Checks whether an update is available for the app.

{% tabs %}
{% tab title="Plain Javascript" %}

```
const { InAppUpdate } = window.WTN;

InAppUpdate.checkIfAppUpdateAvailable({
    callback: function(data) {
        //your logic
    }
});
```

{% endtab %}

{% tab title="ES5+" %}

```
import { InAppUpdate } from "webtonative";

InAppUpdate.checkIfAppUpdateAvailable({
    callback: function(data) {
        //your logic
    }
});
```

{% endtab %}
{% endtabs %}

**Callback Response:**

It will return two keys `isUpdateAvailable` (boolean) and `latestVersion` (string).

```
{ "isUpdateAvailable": true, "latestVersion": "2.0.1" }
```

#### Show In-App Update UI

Displays a native in-app update prompt UI to the user. This allows you to trigger the platform's native update dialog and receive the result via a callback.

{% tabs %}
{% tab title="Plain Javascript" %}

```
const { InAppUpdate } = window.WTN;

InAppUpdate.showInAppUpdateUI({
    callback: function(data) {
        //your logic
    }
});
```

{% endtab %}

{% tab title="ES5+" %}

```
import { InAppUpdate } from "webtonative";

InAppUpdate.showInAppUpdateUI({
    callback: function(data) {
        //your logic
    }
});
```

{% endtab %}
{% endtabs %}

**Callback Response:**

It will return three keys: `type` (string), `isUpdateAvailable` (boolean), and `latestVersion` (string).

| Key                 | Type    | Description                               |
| ------------------- | ------- | ----------------------------------------- |
| `type`              | string  | Always `"showInAppUpdateUI"`              |
| `isUpdateAvailable` | boolean | Whether an update is available            |
| `latestVersion`     | string  | The latest version available on the store |

For Example:

```json
{ "type": "showInAppUpdateUI", "isUpdateAvailable": true, "latestVersion": "2.0.1" }
```

```json
{ "type": "showInAppUpdateUI", "isUpdateAvailable": false, "latestVersion": "1.0.0" }
```

*\*Android and iOS for* checkIfAppUpdateAvailable *and* showInAppUpdateUI *support from 12/03/2026*
