Unity

Install Unity SDK to validate user receipts, get in-app subscription analytics, and 3-rd party integrations.

Install via OpenUPM

Qonversion SDK package is available on the openupm registry. You can install it via openupm-cli.

openupm add com.qonversion.unity

Install via Git URL

Available starting from Unity 2018.3.
Just add this line to the Packages/manifest.json file of your Unity Project:

"dependencies": {
    "com.qonversion.unity": "https://github.com/qonversion/unity-sdk.git#3.4.1"
}

🚧

Installation for Observer Mode

If you are using Qonversion Unity SDK in Observer Mode, please check the Google Play Billing Library version in your in-app subscription implementation. For the library version 3.x.y, you have to use the major version of the SDK 2.x.y. In other cases use the latest SDK version (version 3.0.0 and above).
For the Unity IAP version 4.x.y use the SDK version 2.x.y.

Install Native Dependencies

❗️

Attention

Make sure your project contains the External Dependencies Manager package. Otherwise, iOS & Android dependencies can not be resolved. This can result in the package import issue. Here are the steps to solve this issue:

  1. Download the last version of External Dependencies Manager package.
  2. In the Unity Editor click Import package -> Custom package
  3. Choose a file with .unitypackage dependency from the folder that you've downloaded before and install it.

iOS

  1. Switch your Unity project to iOS.
    1.1 In the Unity select File -> Build Settings.
    1.2 Select iOS from the menu on the left and click Switch platform (will be available if the current platform is not iOS). If the platform selected is iOS already, go to the next step.
  2. In the Unity select Assets -> External Dependency Manager -> iOS Resolver -> Install Cocoapods
  3. Upload your project to a separate folder.
    3.1 In Unity choose File -> Build settings.
    3.2 Select iOS from the menu on the left, then click the Build button.
    3.3 Select the folder where the iOS project will be saved.
  4. Navigate to your iOS project folder in terminal and run pod install command.
  5. Run the project selecting the file with .xcworkspace extension.

Android

  1. Switch your Unity project to Android.
    1.1 In Unity, select File -> Build Settings.
    1.2 Select Android from the menu on the left and click Switch platform (will be available if the current platform is not Android). If the platform selected is Android already, go to the next step.
  2. In Unity select Assets -> External Dependency Manager -> Android Resolver -> Resolve
  3. Upload your project to a separate folder.
    3.1 In Unity choose File -> Build settings.
    3.2 Select Android from the menu on the left.
    3.3 Set Export project checkbox.
    3.4 Click the Export button and select the folder where the Android project will be saved.
  4. Open your Android project in Android Studio (or any other IDE you like).
  5. Enable multidex for your app (if the minSdkVersion property is set to 20 or lower)
    5.1 Select the build.gradle file from the launcher module.
    5.2 Delete the following line at the top of the file:
    // GENERATED BY UNITY. REMOVE THIS COMMENT TO PREVENT OVERWRITING WHEN EXPORTING AGAIN
    5.3 Enable multidex and add the multidex library as a dependency in the above build.gradle file:
defaultConfig {
        ...
        multiDexEnabled true
    }
    ...
}

dependencies {
    ...
    implementation "androidx.multidex:multidex:2.0.1"
}

5.4 In Android Studio select File -> Sync Project with Gradle Files (or the equivalent for your IDE).

Settings for Observer Mode (Android only)

❗️

Duplicated BillingClient classes

If you already have your in-app subscription implementation that uses Google Play Billing Library, you may get a compilation error about duplicate BillingClient classes. To get rid of the error, you can exclude the billingclient dependency which distributes with the Qonversion SDK following the guide below:

  1. In the Unity Editor open the Player Settings window: File -> Build Settings -> Player Settings for Android.
  2. Choose Publishing Settings -> Gradle.
  3. Enable the checkboxes for Custom Main Gradle Template and Custom Gradle Properties Template.
  1. It will generate a mainTemplate.gradle file in theAssets/Plugins/Android/ folder. Add the following strings to the dependencies block of the file:
dependencies {
    ...
    
    configurations.all {
        exclude group: 'com.android.billingclient', module: 'billing'
    }
}
  1. Delete resolved dependencies: Assets -> External Dependency Manager -> Android Resolver -> Delete Resolved Libraries and then Resolve.
  2. Make sure that the Android Resolver added qonversion-sdk to the dependencies list in the build.gradle file for the unityLibrary module:

Setup

Setup with a Launcher

Navigate to the settings in your Qonversion Dashboard and copy the Project Key. Paste it into the Application Access Key field.

Optional

  1. Enable Debug Mode if needed. If debug mode is set to true, user purchases will be checked on the sandbox environment.
  2. Enable Observer Mode if needed. You can read more about Observer Mode in our guide.

Programmatic setup with a Script

Please check the Launching section of our guides for the Observer Mode and the Infrastructure mode.


Did this page help you?