Flutter Cross-Platform SDK
Adding Nami to your app has a few steps for a basic app.
Add the SDK to your project
Configure the SDK
Launch a campaign to show a paywall
React to a purchase to grant access to paid content or features
We'll run through each of these below.
1. Add the SDK to your project
The Nami SDK for Flutter is available on pub.dev. The library is a bridge that links to our full native SDKs and allow access to various Nami capabilities. The Flutter bridge currently supports both Android and iOS.
The code for the Flutter bridge is also available on our GitHub as is an example project.
If you need help setting up your Flutter development environment, you can find instructions here: https://flutter.dev/docs/get-started/install.
To add Nami to your Flutter project, add our package to your project dependencies in your pubspec.yaml
file.
To install the package, run the following on the command line.
2. Configure the SDK
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.
In Flutter apps we recommend placing this code in your initState
method for your class that holds the App State.
First, make sure you have imported the correct modules.
Now to setup Nami, you'll need to call the configure
method with App Platform IDs for both Apple and Google.
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.
3. Launch a campaign to show a paywall
Now that you have the SDK configured, let's show a paywall in your app. This step requires that you have a live Campaign configured in the Control Center with a Paywall.
You may also optionally check if the SDK is able to raise the paywall at the time you are trying to display it.
4. 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.
We recommend creating callback listeners as early as possible in your app to ensure you always have the correct entitlement state. The best spot to do this is right after calling the configure
method.
That's all the basics to get up and running with Nami using Flutter. For more use cases, explore the rest of our docs.
Next Steps
🎉 Congrats on having the basics in place!
Now you are ready to go further based upon your use cases:
Last updated