Start the SDK
The start
must be done as soon as possible to catch every purchase / renewal.
On iOS, initialise the SDK in your AppDelegate
method didFinishLaunchingWithOptions
to allow promoted In-App Purchase and support PSD2.
This initialisation will allow tyou to access products prices instantly later in the app.

import Purchasely
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
Purchasely.start(withAPIKey: "API_KEY", appUserId: "USER_ID")
return true
}
The userID
parameter is optional and allows you to associate the purchase to a user instead of a device.
The eventDelegate
/eventListener
parameter is optional and allows you to listen to all purchases events. You should implement it at least to know when the purchase is successfull.
The uiDelegate
/ uiListener
parameter is optional and allows you to override UI dialog presented to user in case of error or success.
The logLevel
parameter is optional and will display logs from the SDK according to the level set. We advise you to set it to warning or error for production
The stores
parameter (for Android apps) is optional but purchase won't work without it. You need to pass a list of stores that are enabled for your application. The first store available in the user device will be the store used to make a purchase. In this sample, Google Play Billing will be used if available in user device, Huawei Mobile Services will be used otherwise.
The runningMode
parameter is optional and allows you to use Purchasely with another In-App purchase system to prepare a migration. More details in our dedicated section.
Last updated
Was this helpful?