Configuration
This page walks through adding the Affise Unity package to your project, performing any native platform configuration, and initializing the SDK.
Install the UPM package
Section titled “Install the UPM package”From the README verbatim:
Open Package Manager (
Window / Package Manager)Add package from git url
https://github.com/affise/affise-mmp-sdk-unity.git
Alternate install via a downloaded .unitypackage:
Download latest Affise SDK
attribution-1.7.7.unitypackagefrom the releases page and drop this file into the Unity editor.
The package manifest identifier is com.affise.attribution at version 1.7.7 (package.json:2-3).
Project settings
Section titled “Project settings”After import the SDK expects either:
- An
Affise Settings.assetcreated viaEdit / Project Settings / Affise→Createbutton, placed underAssets/Affise/Resources/, or - A manual
Affise.Settings(...).Start()initialization in code.
Native platform setup
Section titled “Native platform setup”The Unity package ships post-build processors that wire up the native Android and iOS plugins.
The bundled Android library lives at Runtime/Plugins/unity.androidlib/ (Runtime/Plugins/unity.androidlib/build.gradle:1). Its manifest at Runtime/Plugins/unity.androidlib/src/main/AndroidManifest.xml:1-3 declares package com.affise.attribution.unity and no permissions.
Gradle configuration for the Android library:
apply plugin: 'com.android.library'
android { compileSdkVersion 30 buildToolsVersion '30.0.2'
compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 }
defaultConfig { targetSdkVersion 30 }}
final affise_version = "1.7.7"
dependencies { implementation "com.android.installreferrer:installreferrer:2.2" // Affise SDK implementation "com.affise:internal:$affise_version"}Build hooks:
- Android post-processor:
Editor/Build/Modules/ModulesAndroidPostProcessBuild.cs:10(implementsIPostGenerateGradleAndroidProject). - Android deeplink preprocessor:
Editor/Build/Deeplink/DeeplinkAndroidBuild.cs:16(implementsIPreprocessBuildWithReport).
Native iOS sources live under Runtime/Plugins/iOS/Source/ and include AffiseLoader.mm, AffiseNativeModule.swift, AffiseUnityBridge.swift, plus base/ (with NativeCallHandler.swift) and utils/.
Build hooks:
- iOS post-processor:
Editor/Build/Modules/ModulesIOSPostProcessBuild.cs:1(guarded by#if UNITY_IOS). - iOS deeplink preprocessor:
Editor/Build/Deeplink/DeeplinkIOSBuild.cs.
Initialize the SDK
Section titled “Initialize the SDK”Initialize by calling Affise.Settings(affiseAppId, secretKey).Start() (Runtime/Affise.cs:41, Runtime/Settings/AffiseSettings.cs:172):
Affise .Settings( affiseAppId: "Your appId", //Change to your app id secretKey: "Your SDK secretKey" //Change to your SDK secretKey ) .Start(); // Start Affise SDKNext steps
Section titled “Next steps”- Customize your initialization: Optional setup.
- Send events: Events tracking.
- Handle deep links: Deep linking.