Installation
Follow these steps to add the Magify Android SDK to your project.
Downloading Magify SDK
Download the latest SDK package.
After downloading the package, unzip the archive.
Adding the local repository
Add the unzipped repository folder to the libs directory at the project level.
If the libs folder does not exist, create it.
<project root>
└── libs/
└── repository/
Configuring the root build file
Open your root build.gradle file and add the local Maven repository:
repositories {
...
// add code below
mavenLocal()
maven {
url = uri("${rootDir}/libs/repository")
}
}
Adding the SDK dependency
Open your module build.gradle file and add the SDK dependency:
dependencies {
...
implementation("com.magify:sdk:4.6.8")
}
Sync your project.
Minimum integration
Minimum integration: from zero to your first campaign in 5 minutes.
1. Add the configuration file
Download Magify-Config.json from the dashboard, or use the dummy configuration below for local testing.
Add the file to your Android app assets.
2. Initialize and call setup
import com.magify.sdk.Magify
// Application class
lateinit var magify: Magify
override fun onCreate() {
val config = MagifyConfig(
applicationName = "android-application", // short app name as listed in the dashboard
defaultConfig = "Magify-Config.json", // only limits and products are expected in the config
isSandbox = false // set to true only for sandbox environment
)
magify = Magify.createInstance(androidApp, config)
// Optional flags — configure before calling setup()
magify.turnOffGeoIP = true
magify.isLoggingEnabled = true
magify.initSdk(
complete = {
// track sdk initialization
}
)
magify.initialSetup()
}
3. Configure clientId
Optionally, provide a custom clientId during SDK initialization.
val config = MagifyConfig(
...
userId = "custom_client_id",
...
)
4. Track purchases
Update subscriptionStatus and inAppStatus.
magify.subscriptionStatus = SubscriptionState.ACTIVE_PAID
magify.inAppStatus = InAppStatus.PURCHASED
5. Sync third-party SDKs
Attribution (AppsFlyer / Adjust).
magify.mediaSource = MediaSource(
network = "appsflyer",
campaign = "ua_01",
adGroup = "us"
)
Dummy Magify-Config.json
Use this file for local development and testing before receiving the real config from the dashboard.
{
"limits": {
"impression_per_session_limit": null,
"sessions_interval": null,
"global_interval": null,
"interstitial_interval": null
},
"native_elements": [],
"campaigns": [],
"features": {},
"content": {}
}
Next step
Now that the SDK is installed, you can proceed to the Configuration section to customize the SDK behavior for your application.
The SDK lifecycle, including foreground updates, is described in the following sections.