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#4.0.0"
}

Install Native Dependencies

❗️

Attention

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

  1. Download the last version of the External Dependencies Manager package.
  2. In the Unity Editor click Import package -> Custom package
  3. Choose a file with the .unitypackage dependency from the folder 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, you can go ahead with 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 the terminal and run the pod install command.
  5. Run the project by selecting the file with the .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 iOS already, you can go ahead with 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
    5.4 In Android Studio select File -> Sync Project with Gradle Files (or the equivalent for your IDE).
defaultConfig {
        ...
        multiDexEnabled true
    }
    ...
}

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

Settings for Analytics 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.
2908
  1. It will generate a mainTemplate.gradle file in the Assets/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:
1074