Integrating Adapty SDK

Requirements

  • iOS 9.0+

  • Xcode 10.2+

You can use Adapty SDK in Swift and Objective-C applications.

Installation

You can install Adapty SDK via CocoaPods, or Swift Package Manager.

Install via CocoaPods

Add Adapty to your Podfile:

Podfile
pod 'Adapty', '~> 1.8.1'

And then run:

pod install

This creates an .xcworkspace file for your app. Use this file for all future development of your application.

Install via Swift Package Manager

  1. In Xcode go to File > Swift Packages > Add Package Dependency...

  2. Enter the repository URL https://github.com/adaptyteam/AdaptySDK-iOS.git

  3. Choose the version, and click Next. Xcode will add the package dependency to your project, and you can import it.

Importing and Configuring Adapty

In your AppDelegate class:

Swift
Swift
import Adapty

And add the following to application(_:didFinishLaunchingWithOptions:):

Swift
Swift
Adapty.activate("PUBLIC_SDK_KEY", customerUserId: "YOUR_USER_ID")

Adapty configurational options:

  • Public SDK key (required): found in your app settings in Adapty Dashboard App settings > General.

  • Customer user ID (optional): an identifier of the user in your system. We send it in subscription and analytical events, to attribute events to the right profile. You can also find customers by customerUserId in the Profiles section. If you don't have user IDs in your app, you can omit this parameter or pass null. If you don't have a user ID at the time of Adapty initialization, you can set it later using .identify() method.

  • Observer mode (optional): a boolean value controlling Observer mode. Turn it on if you handle purchases and subscription status yourself and use Adapty for sending analytical events only.

Make sure you use the Public SDK key for Adapty initialization, the Secret key should be used for server-side API only.

SDK keys are unique for every app, so if you have multiple apps make sure you choose the right one.

Debugging

Adapty logs errors and other important information to help you understand what is going on. There are three levels available:

  1. none (default): won't log anything

  2. errors: only errors will be logged

  3. verbose: method invocations, API requests/responses, and errors will be logged

You can set logLevel in your app before configuring Adapty.

Swift
Swift
Adapty.logLevel = .verbose

Displaying Products

Adapty allows you to remotely configure the products that will be displayed in your app. This way you don't have to hardcode the products and can dynamically change offers or run A/B tests without app releases.

Make sure you've added the products and paywalls in Adapty Dashboard before fethcing them.