SDK Setup
How to setup the Google Play Store Android Nami SDK
Please make sure you have completed the setup of your app on the Nami Control Center for all these steps to be successful.
Adding Nami to your app has a few steps for a basic app.
Add the SDK to your project
Configure the SDK
Show a paywall in your app
React to a purchase to grant access to paid content or features
We'll run through each of these below.
Add the SDK to your project
Google Play Android Requirements
Android SDK minimum version 22
SDK builds target Android 13 (API version 33)
SDK has been built with Java v8 and Kotlin v1.6.10
Our Android SDK is available via our Maven repository. Add the following code snippet to your project's build.gradle
to add the Nami SDK to your project.
Enterprise customers may have a custom Maven repo. Contact Team Nami to learn more and make sure you are referencing the correct repository.
Then in the build.gradle
for your app add the following code, replacing the version number with whichever version of the Nami SDK you would like to run.
Release notes for the Android SDK is available here.
Add compileOptions
for Java 8 compatibility in your appbuild.gradle
.
Supporting Android SDK minimum version 25
If your app need to support Android SDK minimum version 25, see this doc for two additional steps to enable the Nami SDK to work properly.
Configure the SDK
Use Android Studio to Get Code Documentation
The Nami SDK was built with Dokka and if you use Android Studio, you'll get helpful code completions and documentation about methods.
We recommend that you configure the Nami SDK as early in your app's launch as possible. This will ensure the SDK is ready to receive and process purchases.
The best spot to do this is in the onCreate()
method in your class that creates your Application
and inherits from Application()
. Here's a full code example.
You'll need to go find your App Platform ID in the Control Center > Integrations > Google Play for this step.
Nami recommends setting the log level to WARN
for apps on the store. INFO
may be helpful during development to better understand what is going on. DEBUG
level has a lot of information and is likely only helpful to the Nami support team.
Show a paywall
Now that you have the SDK configured, let's show a paywall in your app.
This step requires that you have designed a paywall and attached it to a live campaign.
Grant access to paid app features
Once a user has made a purchase, you'll need to make sure to give them access to the content and features in your app that require a purchase. This is managed on the Nami platform through our entitlement engine.
The first option is to check whether a specific entitlement is active. This is done with the following code.
Nami also triggers a callback any time there is a change to the state of an entitlement. In the callback the full list of currently active entitlements is provided. You can use this to store the state of whether a user has access to premium features locally in your app.
It is important that any callbacks are created as early in the app launch as possible. We recommend adding the callback handlers in the NamiSetup
method in your AppDelegate.cs
.
That's all the basics to get up and running with Nami for Google Play - Android apps.
Next Steps
🎉 Congrats on having the basics in place!
Now you are ready to go further based upon your use cases:
Last updated