# Cordova SDK

## Installation

### **NPM**

You can use [NPM](https://www.npmjs.com/package/@purchasely/cordova-plugin-purchasely) to install **Purchasely** by running this command in your project:

```bash
cordova plugin add @purchasely/cordova-plugin-purchasely
```

Don't forget to change the minimum OS versions to match Purchasely requirements (iOS 11 / Android 21)

### iOS Integration

You must have an iOS platform for your project. If it is not the case, you can simply add it with a cordova command :

```markup
cordova platform add ios
```

### Android Integration

#### Enable AndroidX

AndroidX is mandatory to display our paywalls, it is [deactivated by default](https://cordova.apache.org/announcements/2020/06/29/cordova-android-9.0.0.html). You can enable it easily by editing your config.xml file.

```markup
<platform name="android">
    <allow-intent href="market:*" />
    <preference name="AndroidXEnabled" value="true" />
</platform>
```

#### Add Android platform

You must have an Android platform for your project. If it is not the case, you can simply add it with a cordova command :

```markup
cordova platform add android
```

#### Add Stores dependencies

Our Cordova SDK does not contains a store to avoid unnecessary integrations. You have to specifically declare which stores you want. To add Android dependencies to your project, you need to create a file `platforms/android/app/build-extras.gradle`

Then you add the stores dependencies you wish to use.

{% tabs %}
{% tab title="build-extras.gradle" %}

```bash
dependencies {
    //Google Play Store
    implementation 'io.purchasely:google-play:2.8.0'
    
    //Amazon App Store
    implementation 'io.purchasely:amazon:2.8.0'
    
    //Huawei Mobile Services
    implementation 'io.purchasely:huawei-services:2.8.0'
}
```

{% endtab %}
{% endtabs %}

#### Huawei Integration

Huawei needs a little more configuration to work properly, to integrate Huawei Mobile Services, please refer to our Android documentation : <https://docs.purchasely.com/quick-start/sdk-installation/quick-start#huawei-mobile-services>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://purchasely.gitbook.io/purchasely/2.8/quick-start/sdk-installation/cordova.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
