Nami Public Documentation
Sign In
Nami Documentation
Nami Documentation
  • Get Started
    • Overview
      • Key Concepts
      • Data Collection
      • Built for Privacy
    • Evaluating Nami
    • SDKs
      • Apple Native SDK
      • Android Native SDK
      • Amazon Native SDK
      • Roku Native SDK
      • React Native Cross-Platform SDK
      • Flutter Cross-Platform SDK
      • Unity Cross-Platform SDK
      • Release Notes
        • Find Nami SDK Version
    • Quickstart Guide
  • Subscription Management
    • Overview
    • Products
      • Archive Products
      • Sync Products
    • Entitlements
    • Customer Screen
    • Accounts and Login/Logout
    • Advanced Use Cases
      • Upgrades and Downgrades
      • Supported Purchase Change States by Platform
      • Restoring Purchases
      • Working with Consumable IAPs
  • No Code Paywalls
    • Overview
    • Paywall Creator
      • Using the Creator
      • Paywall Layout
      • Components
        • Editing, Deleting, Reordering
        • Hiding Components
        • Video
        • Collapse
      • Editable Properties
        • Focused Styling
        • Safe Area
      • Conditions
        • Notched Devices
        • Product Entitlements
      • Adding Products
      • Repeating Product Group
      • Product Fields
      • Capabilities
        • Featured Styling
        • Selected Styling
        • Custom Brand Fonts
        • Carousel
        • Trial Eligibility
        • Deeplink Button
        • Introductory Offer Eligibility
        • Login Check
        • Product Groups
        • Conditional Product Groups
        • Offer Eligibility and Purchasing
        • Screenreader Text
        • Personalization Tokens
        • Custom Variables
        • Multipage
        • Custom Data Source
        • Advanced Video Features
        • Product Error States
      • ❓FAQs
        • Designing Paywalls in Figma
        • Guide to Building a Paywall from Scratch
      • 🎁Releases
        • Roadmap
    • Paywall Templates
      • Pacific
      • Pacific Premium
      • Trident
      • Starfish
      • Mantis
      • Venice
      • Venice Premium
      • Honest
      • Catalina
      • Oyster
      • Puffin
      • Marina
      • Beluga
      • Driftwood
      • Lagoon
      • Pisces
      • Aquarius
      • Conch
      • Lionfish
      • Moray
      • Tetra
      • Lighthouse
      • Puffin Tablet
    • Managing Paywalls
      • Archiving a Paywall
      • Duplicate a Paywall
    • Paywall Smart Text
    • Pricing Eligibility States
    • Pricing Eligibility by Platform
    • Nami Paywalls in Different Languages
    • Legacy Paywalls
  • Campaigns
    • Placements
      • Create a Placement
      • Deeplink Placements
      • Archiving a Placement
      • Managing Lots of Placements
      • Export Placements
    • Campaigns
      • Campaign Filters
        • Campaign Use Cases
      • Archiving a Campaign
      • Scheduling a Campaign
      • Campaign Conversion Events
      • Managing Lots of Campaigns
      • Campaign Troubleshooting
    • A/B and Multivariate Testing
      • Selecting an A/B test winner
      • A/B Test Allocation
  • Integrations
    • All Integrations
    • Billing Platforms
      • Apple Integration
        • App Store Setup
          • Privacy Details
        • Platform Integration
        • App Store Server Notifications
        • Store Credentials
          • App Store Connect Shared Secret
          • Apple App Store Connect API
          • Apple In App Purchase
        • Add a Product
        • Platform Sync
        • SDK Integration
        • Troubleshooting
        • Testing and Development
          • Apple Testing Environments
          • Setting up Device Sandbox Test Environment
          • Setting up StoreKit config in Xcode
      • Google Integration
        • Google Play Store Setup
        • Platform Integration
        • Service Account
        • Real-time Developer Notifications
        • Add a Product
        • Platform Sync
        • SDK Setup
        • Troubleshooting
          • Supporting Android minSdkVersion 25 or lower
          • Requested product is not available for purchase
          • Unsupported Version of Play Billing
      • Amazon Appstore Integration
        • Create Amazon Android App
        • Platform Integration
        • Shared Key
        • Real-time Event Notifications
        • Add a Product
        • SDK Integration
        • Testing
      • Roku Integration
        • Platform Integration
        • API Key
        • Transaction Notifications
        • Add a Product
        • SDK Integration
      • Web Integration
    • Analytics Tools
      • Adobe Analytics
      • Amplitude
      • Google Analytics
      • mParticle
      • 3rd-Party Analytics
    • Subscription Management
      • Nami Subscription Management
      • Bring your Own Payment Code
    • CDP Integrations
      • Adobe CDP Integration
      • Amplitude CDP Integration
      • Custom CDP Integration
      • Generic CDP Integration
    • Other Integrations
      • Wicket Labs
      • Webhooks
        • Introduction to the Nami ML Event System
        • Event Types
          • Purchase Status Updates
          • Events for Upgrades, Downgrades, and Crossgrades
        • Event Subscriptions
        • Understanding Transferred Events and Accounts
      • API Access
    • Events Feed
  • Analytics
    • Using Charts
    • Paywall Analytics
      • Impressions
      • Paywall Conversion Rate
      • Sessions
      • Active Devices
    • Subscription Analytics
      • Revenue
      • MRR
      • Purchases
      • Trial Starts
  • Nami Account
    • Manage your Apps
      • Find your Nami App Platform ID
      • Setting up Legal Text for your Apps
    • Organization
      • Configuring Organization Security Policies
      • Billing
    • Invite your Team
      • Roles
    • Manage your Account
      • Two-Factor Authentication (2FA)
Powered by GitBook
On this page
  • Add the SDK to your project
  • Configure the SDK
  • Show a paywall
  • Grant access to paid app features
  1. Integrations
  2. Billing Platforms
  3. Apple Integration

SDK Integration

How to setup the Apple Nami SDK

Last updated 8 months ago

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.

  1. Add the SDK to your project

  2. Configure the SDK

  3. Show a paywall in your app

  4. React to a purchase to grant access to paid content or features

We'll run through each of these below.

Nami works with SwiftUI apps! But there are a few small differences in a SwiftUI setup. Please look for additional callouts below and separate code samples for SwiftUI implementation of the Nami Platform.

Add the SDK to your project

Requirements

The Nami Apple SDK supports

  • iOS 14+

  • iPadOS 14+

  • tvOS 15+

  • Xcode 12+

Our Apple SDK is available on , with sample applications and our Nami Apple SDK.

The best way to add Nami to your project is to use the Swift Package Manager (SPM) to install the latest SDK version into your application.

We also support CocoaPods and you can manually install the XCFramework from our GitHub repository.

SPM using Xcode on the Mac:

  1. In the Xcode menu select File > Add Packages.

  2. In the box below, select Dependency Rule: 'Branch' and enter the current SPM version name

  1. Select "Add Package"

  2. Verify the SPM package is loaded by looking at the project Navigator

Manual Setup

  1. Copy NamiApple.xcframework from the downloaded GitHub repository into the same directory as your application .xcproject file.

  2. Open your project in Xcode, select the application target in the project navigator.

  3. Select the General tab if it is not already selected.

  1. Drag the NamiApple.framework in the same directory as your .xcproject file from Finder into the project Frameworks, libraries and Embedded Content section of the General tab. Make sure Embed and Sign is selected.

  1. After this, the NamiApple framework is installed.

  2. To update, download new versions of the NamiApple.framework from the GitHub repository, and copy them on top of the Nami.framework in your application - always opt to replace the entire directory when copying.

  3. You may wish to optionally check the Nami.framework into your application repository if you are using source control.

Cocoapods

We recommend you switch to the Swift Package Manager as the best way to integrate the Nami framework into your app.

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.

For Swift, the best spot to do this is in the ApplicationDidFinishLaunchingWithOptions method in the AppDelegate.swift.

For SwiftUI, we recommend adding an init() method if not already present, to your App subclass that starts your application, usually in a file called YourAppNameApp.swift file. We also recommend that you encapsulate the Nami configuration in its own method.

For Objective-C, the best spot to do this is indidFinishLaunchingWithOptions method in the AppDelegate.m.

Here's a full code example:

import NamiApple

class AppDelegate: UIResponder, UIApplicationDelegate {
  func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    let namiConfig : NamiConfiguration = NamiConfiguration( appPlatformId: "YOUR_APP_PLATFORM_ID" )
    namiConfig.logLevel = .warn
    Nami.configure(with: namiConfig)
  }
}
import NamiApple

@main
struct ExampleApp: App {
      
  init() {
    let namiConfig : NamiConfiguration = NamiConfiguration( appPlatformId: "YOUR_APP_PLATFORM_ID" )
    namiConfig.logLevel = .warn
    Nami.configure(with: namiConfig)
  }
  
  var namiDataSource = NamiDataSource()
    
  var body: some Scene {
    WindowGroup {
      ContentView().environmentObject(namiDataSource)
    }
  }
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
	 // Find your appPlatformID in Control Center > Integrations
   NamiConfiguration *namiConfig = [NamiConfiguration configurationForAppPlatformID: @"YOUR_APP_PLATFORM_ID"];
   [namiConfig setLogLevel:NamiLogLevelWarn];
   [Nami configureWithNamiConfig:namiConfig];

  return YES
}

You'll need to go find your App Platform ID in the Control Center > Integrations to configure the SDK.

Nami recommends setting the log level to .warn for apps published to the App 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.

SwiftUI NamiDataSource

For SwiftUI apps, you'll see that we referenced a NamiDataSource. You'll need to create this class and publish events to it to use throughout your application.

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.

Campaigns are used to setup the various placements and contexts in your app where you may want to show a paywall.

To raise a paywall for a "default campaign", which is one without a label, just call launch like this:

NamiCampaignManager.launch()

If you campaign has a label, you can launch it like this:

NamiCampaignManager.launch(label: "your_campaign_label")

That's it!

If you're using Nami for purchase/subscription-management see below for details on how to gate access using our entitlement engine.

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.

if NamiEntitlementManager.isEntitlementActive("premium_access") {
 	// allow access to premium app features 
}

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 ApplicationDelegate.swift or ApplicationDelegate.m.

NamiEntitlementManager.registerChangeHandler()  { activeEntitlements in
  for ent in activeEntitlements {
    let ent_id = ent.referenceID
    // use the active entitlements reference IDs to grant
    // access to premium app features
  }
}

That's all the basics to get up and running with Nami on Apple. For more use cases, explore the rest of our docs.

SwiftUI

In order to react to changes in the entitlement state of a user in your SwiftUI app, you need to create an ObservableObject you can use to store this state in your app.

The class below shows how to create the NamiDataSource object we used in the Configure the SDK section above. This code will work for any app that only has a single entitlement (the user has access to the paid content or not).

If your app has multiple entitlements or you need to store something like a credit balance, simply create additional @Published variables to store the data you need.

class NamiDataSource: ObservableObject { 
  @Published var purchased = false

  private var listener: NSObjectProtocol?
  
  init() {    
    purchased = (NamiEntitlementManager.available().count > 0)
 
    // react to changes to entitlement state
    NamiEntitlementManager.registerChangeHandler { (activeEntitlements) in
       self.purchased = (activeEntitlements.count > 0)
    }
  }
}

Now to react to the entitlement state of your users, simply reference the NamiDataSource object in your View and access any of the @Published variables. In this case, we simply need to check the boolean purchased.

struct ExampleView: View {
  @EnvironmentObject var namiDataSource: NamiDataSource
  
  var body: some View {
    if namiDataSource.purchased {
      // react to active entitlement 
    }
  }
}

In the right-hand corner of the modal in the box labelled 'Search or Enter Package URL', enter the URL .

Download the Nami SDK from GitHub at

Nami is available via .

We'll discuss this more in the section below.

For more advance integrations, launch provides a variety of to give you insight into the campaign, including paywall interactions.

GitHub
https://github.com/namiml/NamiSDK-SwiftPackageManager
https://github.com/namiml/nami-apple
Cocoapods
callbacks
Grant access to paid app features