Set up Nami in your App
Now that the Nami SDK has been added to your project, let's set up Nami in your app.
Apple
Add Nami to your application delegate
- Open the file
AppDelegate.swift
orAppDelegate.m
in your project and import Nami.
- Configure Nami by passing the SDK your
Nami App Platform ID
.
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Configure Nami
let namiConfig = NamiConfiguration(appPlatformID: "YOUR_APP_PLATFORM_ID_GOES_HERE")
// optionally adjust the level of logging of the SDK
// .debug, .info, .warn, .error, defaults to .warn
namiConfig.logLevel = .info
Nami.configure(namiConfig: namiConfig)
return true
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
NamiConfiguration *namiConfig = [NamiConfiguration configurationForAppPlatformID: @"YOUR_APP_PLATFORM_ID"];
// optionally adjust the level of logging of the SDK
// Debug, Info, Warn, Error, defaults to Warn
[namiConfig setLogLevel:NamiLogLevelInfo];
[Nami configureWithNamiConfig:namiConfig];
return YES;
}
Nami App Platform ID
Need to find your Nami App Platform ID? Follow these instructions.
Nami Best Practice
If you plan on using more advanced configuration of the Nami SDK, we recommend moving all the Nami setup code to its own method.
Also, if you have existing code in
didFinishLaunchingWithOptions
, it is best to call the Nami configure method as soon as possible so the system can initialize and your app will be ready to process purchases.
You Must Have Products Setup in App Store Connect
In order for one of our cloud-based paywalls to raise when you test the SDK, your paywalls must have a product that is set up correctly in App Store Connect.
If you need help creating in-app purchase products, check out Apple's documentation here.
iOS 14+ Simulators
If you are running the Nami SDK in a simulator running iOS 14 or newer, you will not see your product SKUs on a paywall unless you either run in
bypass store
mode or create a StoreKit configuration file.Read more on bypass store here.
For details on creating a StoreKit configuration file, read this article.
Android
To use the Nami SDK in your Android app, you need to initialize the SDK in the onCreate
method of your Application class.
import com.namiml.Nami
import com.namiml.NamiConfiguration
import com.namiml.NamiLogLevel
class DemoApplication : Application() {
companion object {
private const val NAMI_APP_PLATFORM_ID = "insert your app platform id"
}
override fun onCreate() {
super.onCreate()
Nami.configure(
NamiConfiguration.build(this, NAMI_APP_PLATFORM_ID) {
// log level can be set to DEBUG, INFO, WARN, and ERROR
logLevel = NamiLogLevel.DEBUG
}
)
}
}
import com.namiml.Nami;
import com.namiml.NamiConfiguration;
import com.namiml.NamiLogLevel;
public class DemoApplication extends Application {
private static final String NAMI_APP_PLATFORM_ID = "insert your app platform id";
@Override
public void onCreate() {
super.onCreate();
NamiConfiguration.Builder builder = new NamiConfiguration
.Builder(this, NAMI_APP_PLATFORM_ID)
.logLevel(NamiLogLevel.DEBUG);
Nami.configure(builder.build());
}
}
Need to find your Nami App Platform ID? Follow these instructions.
Nami Best Practice
We recommend configuring your logging for the Nami SDK to be automatically tied to your build config so you do not accidentally ship a production release of your app with the logging turned up to a high level.
You can accomplish this by setting your logging with the following code snippet for Kotlin:
logLevel = NamiLogLevel.DEBUG.takeIf { BuildConfig.DEBUG } ?: NamiLogLevel.WARN
or in Java:
if (BuildConfig.DEBUG) { builder.logLevel(NamiLogLevel.DEBUG); }
React Native
To use Nami in your React Native code, make sure you have imported both the NativeModules
and NativeEventEmitter
into each of your javascript files where you'll be using the Nami SDK.
import {
NativeEventEmitter,
NativeModules
} from 'react-native';
In order to register your React Native app with Nami, add your application ID to the first screen that loads in your app. Set up your Nami application ID in the useEffect
or componentDidMount
method.
useEffect(() => {
var configDict = {
"appPlatformID-google": "YOUR_PLAY_STORE_APP_PLATFORM_ID",
"appPlatformID-apple": "YOUR_APP_STORE_APP_PLATFORM_ID",
"logLevel": "INFO", // optionally set SDK logging level, default:WARN
"developmentMode": true // turn on features to help with integrating SDK
};
NativeModules.NamiBridge.configure(configDict);
}, []);
componentDidMount(){
var configDict = {
"appPlatformID-google": "YOUR_GOOGLE_APP_PLATFORM_ID",
"appPlatformID-apple": "YOUR_GOOGLE_APP_PLATFORM_ID",
"logLevel": "INFO", // optionally set SDK logging level, default:WARN
"developmentMode": true // turn on features to help with integrating SDK
};
NativeModules.NamiBridge.configure(configDict);
}
Need to find your Nami App Platform ID? Follow these instructions.
Nami Best Practice
We recommend making sure your call to
useEffect
has the second parameter of the empty array. This ensures thatuseEffect
is not run on every screen re-render.
Updated over 3 years ago
Set up your in-app purchase experience in the Nami Control Center.