### Complete Android Installation Example Source: https://github.com/purchasely/documentation/blob/v5.7/platform/react-native.md Example of installing all required dependencies for an app distributed on Google Play Store with video paywalls, followed by SDK initialization. ```shell # Install all required dependencies npm install react-native-purchasely --save npm install @purchasely/react-native-purchasely-google --save npm install @purchasely/react-native-purchasely-android-player --save ``` -------------------------------- ### Complete Android Installation Example Source: https://github.com/purchasely/documentation/blob/v5.7/platform/cordova.md Example command to install both the core Purchasely SDK and the Google Play Billing dependency for Android. ```shell # Install all required dependencies cordova plugin add @purchasely/cordova-plugin-purchasely cordova plugin add @purchasely/cordova-plugin-purchasely-google ``` -------------------------------- ### Start Purchasely SDK in Swift Source: https://github.com/purchasely/documentation/blob/v5.7/docs/🔌 Integrations/3rd-party-integrations/revenuecat.md Call the `start` method as early as possible in your application lifecycle to ensure all purchases and renewals are captured. This example shows basic configuration with an API key and debug logging. ```Swift import Purchasely func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { Purchasely.start(withAPIKey: "API_KEY, appUserId: nil, runningMode: .paywallObserver, eventDelegate: nil, logLevel: .debug) { (success, error) in print(success) } return true } ``` -------------------------------- ### Retrieve User Subscriptions in Unity (C#) Source: https://github.com/purchasely/documentation/blob/v5.7/docs/🚀 Getting Started/sdk-quick-start/entitlements-management/dashboard-subscription-status.md This example shows how to get user subscriptions using a callback for success and another for logging errors. It iterates through the subscription data, logging details about the plan and product. Remember that there's a delay for updates post-purchase. ```csharp private PurchaselyRuntime.Purchasely _purchasely; ... _purchasely.GetUserSubscriptions(OnGetSubscriptionsSuccess, Log); ... private void OnGetSubscriptionsSuccess(List subscriptionData) { Log("Get Subscription Data Success."); foreach (var subscription in subscriptionData) { Log($"Subscription ID: {subscription.id}"); var plan = subscription.plan; if (plan != null) LogPlan(plan); var product = subscription.product; if (product != null) LogProduct(product); } } ``` -------------------------------- ### Installation Source: https://context7.com/purchasely/documentation/llms.txt Details on how to install the Purchasely SDK using package managers for different platforms. ```APIDOC ## Installation SDK packages and dependencies per platform. ```bash # iOS — CocoaPods pod 'Purchasely' # or Swift Package Manager: https://github.com/Purchasely/Purchasely-iOS ``` ``` -------------------------------- ### Standalone Connection Execution Example Source: https://github.com/purchasely/documentation/blob/v5.7/docs/✈️ GOING FURTHER/byos/byos-implementation.md Example of how to find a specific connection by its ID and then execute it using the presentation object. ```swift let loginConnection = presentation.connections.first(where: { $0.id == "login" }) presentation.executeConnection(loginConnection) ``` ```kotlin val connection = presentation.connections.firstOrNull { it.id == "login" } presentation.execute(connection) ``` -------------------------------- ### Install with Carthage Source: https://github.com/purchasely/documentation/blob/v5.7/custom_blocks/IosSdkInstallation.md Add this line to your Cartfile to install the SDK using Carthage. ```plaintext binary "https://raw.githubusercontent.com/Purchasely/Purchasely-iOS/master/Purchasely.json" ``` -------------------------------- ### Using DURATION Tag Example Source: https://github.com/purchasely/documentation/blob/v5.7/docs/📱 Screens & Paywalls/screen-composer/tags.md Provides an example of the DURATION tag, which displays the total subscription duration, like '1 month' or '1 year'. ```text Access for {{DURATION}} ``` -------------------------------- ### Install React Native SDK Source: https://github.com/purchasely/documentation/blob/v5.7/custom_blocks/ReactnativeSdkInstallation.md Install the main Purchasely React Native SDK using NPM. Ensure your project meets the minimum OS version requirements. ```shell npm install react-native-purchasely --save ``` -------------------------------- ### Install Unity SDK Source: https://github.com/purchasely/documentation/blob/v5.7/docs/🚀 Getting Started/general-quick-start-guide/general-sdk-installation/index.md Add this dependency to your Unity project's XML configuration for integration. ```xml io.purchasely unity [4.0,4.999] ``` -------------------------------- ### Install Purchasely with Swift Package Manager Source: https://github.com/purchasely/documentation/blob/v5.7/custom_pages/onboarding-apple-setup.md Use Swift Package Manager to add the Purchasely SDK to your project. ```Text install Purchasely ``` -------------------------------- ### Example Workflow for Compiling All Platforms Source: https://github.com/purchasely/documentation/blob/v5.7/compilation/SDK_COMPILATION_README.md This sequence of commands demonstrates a complete workflow for compiling all SDK documentation platforms, from checking status to cleaning up afterwards. ```bash # 1. Check what's already compiled ./compile_sdk_docs.sh check # 2. Create sequential compilation workflow ./open_claude_compiler.sh interactive # 3. Start compilation (in Claude Code) cat COMPILE_ALL_SEQUENTIAL.md # 4. Monitor progress ./compile_sdk_docs.sh check # 5. Clean up when done ./compile_sdk_docs.sh clean ``` -------------------------------- ### Initialize Purchasely SDK in Swift Source: https://github.com/purchasely/documentation/blob/v5.7/docs/🚀 Getting Started/sdk-quick-start/sdk-initialization.md Call `Purchly.start` as the first method in your application's launch process. Ensure you replace '<>' with your actual API key. The `runningMode` can be set to `.full` or `.paywallObserver`, and `storekitSettings` can be `.storeKit2`. ```swift import Purchasely func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { Purchasely.start( withAPIKey: "<>", appUserId: nil, // optional if you already know your user id runningMode: .full, // select between full and paywallObserver storekitSettings: .storeKit2, // Set your StoreKit version logLevel: .debug ) {(success, error) in print(success) } return true } ``` -------------------------------- ### Get Anonymous User ID Source: https://github.com/purchasely/documentation/blob/v5.7/platform/flutter.md Retrieve the automatically generated anonymous user ID. This ID remains consistent for the app installation on a device. ```dart // Get the anonymous user ID String anonymousId = Purchasely.anonymousUserId; print('Anonymous User ID: $anonymousId'); ``` -------------------------------- ### Initialize Purchasely SDK in Swift (iOS) Source: https://context7.com/purchasely/documentation/llms.txt Call `Purchasely.start()` once at app launch. Ensure the API key, running mode, and StoreKit version are correctly configured. Handles success or error callbacks. ```swift import Purchasely func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { Purchasely.start( withAPIKey: "YOUR_API_KEY", // from Console → App settings → Backend & SDK configuration appUserId: nil, // set if user is already logged in runningMode: .full, // .full or .paywallObserver storekitSettings: .storeKit2, // .storeKit1 or .storeKit2 logLevel: .debug // .debug (dev) / .error (prod) ) { (success, error) in if success { print("SDK ready") } else { print("SDK init failed: \(error?.localizedDescription ?? \"unknown\")") } } return true } ``` -------------------------------- ### Get Anonymous User ID Source: https://github.com/purchasely/documentation/blob/v5.7/platform/react-native.md Retrieve the automatically generated anonymous user ID. This ID remains consistent as long as the app is installed on the device. ```typescript // Get the anonymous user ID const anonymousId = await Purchasely.getAnonymousUserId(); console.log('Anonymous User ID: ' + anonymousId); ``` -------------------------------- ### Get Anonymous User ID in Cordova Source: https://github.com/purchasely/documentation/blob/v5.7/platform/cordova.md Retrieve the unique anonymous user ID generated by the Purchasely SDK. This ID remains consistent as long as the app is installed on the device. ```javascript // Get the anonymous user ID Purchasely.getAnonymousUserId((anonymousId) => { console.log('Purchasely anonymous Id: ' + anonymousId); }); ``` -------------------------------- ### Initialize Purchasely SDK with API Key Source: https://github.com/purchasely/documentation/blob/v5.7/docs/Onboarding/sdk_initialisation/sdk_initialisation_cordova.md Call this method to start the SDK. Provide your API key, specify the stores to integrate with, and optionally set user ID, log level, and running mode. ```javascript /** * @params String apiKey * @params StringArray stores : may be Google, Amazon and Huawei * @params String userId * @params Purchasley.LogLevel logLevel * @params Purchasely.RunningMode runningMode **/ Purchasely.startWithAPIKey( '<>', ['Google'], true, // true for StoreKit 1, false for StoreKit 2 null, // user id of user Purchasely.LogLevel.DEBUG, Purchasely.RunningMode.full ); ``` -------------------------------- ### Start Purchasely SDK in Kotlin Source: https://github.com/purchasely/documentation/blob/v5.7/docs/🔌 Integrations/3rd-party-integrations/revenuecat.md Configure and build the Purchasely SDK using the Builder pattern. Ensure to call `Purchasely.start()` after configuration to fetch products and configurations from the specified stores. Debug logging is recommended for development. ```Kotlin import io.purchasely.ext.Purchasely Purchasely.Builder(applicationContext) .apiKey("API_KEY") .logLevel(LogLevel.DEBUG) // set to warning or error for release .userId("USER_ID") .runningMode(PLYRunningMode.PaywallObserver) .stores(listOf(GoogleStore(), HuaweiStore())) .build() // When you are ready for Purchasely to initialize, // you must call start() method that will grab configuration and products // from the selected stores. Purchasely.start { isConfigured -> } ``` -------------------------------- ### Initialise Purchasely SDK in Swift Source: https://github.com/purchasely/documentation/blob/v5.7/docs/Onboarding/sdk_initialisation/sdk_initialisation_swift.md Call this method in your application's entry point to start the Purchasely SDK. Provide your API key, optionally a user ID, running mode, StoreKit version, and log level. A callback is provided to handle the success or failure of the initialisation. ```swift import Purchasely func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { Purchasely.start( withAPIKey: "<>", appUserId: nil, // optional if you already know your user id runningMode: .full, storekitSettings: .storeKit1, // Set your StoreKit version logLevel: .debug ) {(success, error) in print(success) } return true } ``` -------------------------------- ### Install with CocoaPods Source: https://github.com/purchasely/documentation/blob/v5.7/custom_blocks/IosSdkInstallation.md Add this line to your Podfile to install the SDK using CocoaPods. ```ruby pod 'Purchasely' ``` -------------------------------- ### Initialize Purchasely SDK in Swift Source: https://github.com/purchasely/documentation/blob/v5.7/docs/🚀 Getting Started/general-quick-start-guide/general-sdk-initialization.md Call `Purchasely.start` with your API key, an optional user ID, and a log level. The callback provides initialization success status and potential errors. ```swift import Purchasely func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { Purchasely.start( withAPIKey: "<>", appUserId: nil, // optional if you already know your user id logLevel: .debug ) {(success, error) in print(success) } return true } ``` -------------------------------- ### Initialize SDK for iOS Source: https://github.com/purchasely/documentation/blob/v5.7/recipes/sdk-implementation.md Call the start method to initialize the SDK. No API key is explicitly shown in this snippet. ```swift Purchasely.start() ``` -------------------------------- ### Install Android Video Player Source: https://github.com/purchasely/documentation/blob/v5.7/custom_blocks/ReactnativeSdkInstallation.md Install the external dependency for the video player on Android. This is automatically detected and handled by the SDK. ```shell npm install @purchasely/react-native-purchasely-android-player --save ``` -------------------------------- ### StoreKit 1 Purchase Flow Example Source: https://github.com/purchasely/documentation/blob/v5.7/docs/🐣 Starting with In-App Purchases & Subscriptions/app-store-storekit-1-vs-storekit-2.md Demonstrates the traditional StoreKit 1 approach for initiating a purchase and handling transaction states using delegate callbacks. Requires manual transaction finishing. ```swift let payment = SKPayment(product: product) SKPaymentQueue.default().add(payment) func paymentQueue(_ queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction]) { for transaction in transactions { switch transaction.transactionState { case .purchased: // Unlock content SKPaymentQueue.default().finishTransaction(transaction) case .restored: // Restore purchases SKPaymentQueue.default().finishTransaction(transaction) case .failed: // Handle error SKPaymentQueue.default().finishTransaction(transaction) default: break } } } ``` -------------------------------- ### Usage Example: Set Custom Screen View Delegate (Swift) Source: https://github.com/purchasely/documentation/blob/v5.7/docs/✈️ GOING FURTHER/byos/byos-implementation.md Example of how to instantiate and set a custom screen view delegate in Swift. ```swift let customScreenDelegate = CustomScreenViewDelegate() Purchasely.setCustomScreenViewDelegate(customScreenDelegate) ``` -------------------------------- ### SDK Initialization Source: https://context7.com/purchasely/documentation/llms.txt The `Purchasely.start()` method must be called once at app launch before any other SDK method. It accepts an API key, an optional user ID, the running mode, StoreKit version (iOS), Android stores, and log level. It returns a success/error callback. ```APIDOC ## SDK Initialization `Purchasely.start()` — must be called once at app launch before any other SDK method. Accepts API key, optional user ID, running mode, StoreKit version (iOS), Android stores, and log level. Returns a success/error callback. ```swift // iOS (Swift) — AppDelegate.swift import Purchasely func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { Purchasely.start( withAPIKey: "YOUR_API_KEY", // from Console → App settings → Backend & SDK configuration appUserId: nil, // set if user is already logged in runningMode: .full, // .full or .paywallObserver storekitSettings: .storeKit2, // .storeKit1 or .storeKit2 logLevel: .debug // .debug (dev) / .error (prod) ) { (success, error) in if success { print("SDK ready") } else { print("SDK init failed: \(error?.localizedDescription ?? \"unknown\")") } } return true } ``` ```kotlin // Android (Kotlin) — Application.kt import io.purchasely.ext.Purchasely import io.purchasely.ext.PLYRunningMode import io.purchasely.ext.LogLevel import io.purchasely.google.GoogleStore class MyApp : Application() { override fun onCreate() { super.onCreate() Purchasely.Builder(applicationContext) .apiKey("YOUR_API_KEY") .userId(null) .stores(listOf(GoogleStore())) // GoogleStore(), HuaweiStore(), AmazonStore() .logLevel(LogLevel.DEBUG) .runningMode(PLYRunningMode.Full) // PLYRunningMode.PaywallObserver .build() .start { isConfigured, error -> if (isConfigured) Log.d("PLY", "SDK ready") else Log.e("PLY", "SDK init failed: ${error?.message}") } } } ``` ```typescript // React Native — App.tsx import Purchasely, { LogLevels, RunningMode } from 'react-native-purchasely'; try { const configured = await Purchasely.start({ apiKey: 'YOUR_API_KEY', storeKit1: false, // false = StoreKit 2 (recommended) logLevel: LogLevels.ERROR, // LogLevels.DEBUG in development userId: null, runningMode: RunningMode.Full, // RunningMode.PaywallObserver androidStores: ['Google'] // requires @purchasely/react-native-purchasely-google }); if (configured) console.log('SDK ready'); } catch (e) { console.error('SDK init failed', e); } ``` ```dart // Flutter — main.dart import 'package:purchasely_flutter/purchasely_flutter.dart'; bool configured = await Purchasely.start( apiKey: 'YOUR_API_KEY', androidStores: ['Google'], // requires purchasely_google package storeKit1: false, logLevel: PLYLogLevel.error, // PLYLogLevel.debug in development runningMode: PLYRunningMode.full, // PLYRunningMode.paywallObserver userId: null, ); if (!configured) throw Exception('SDK init failed'); ``` ``` -------------------------------- ### Start Purchasely SDK Source: https://github.com/purchasely/documentation/blob/v5.7/custom_pages/onboarding-apple-setup.md Initialize the Purchasely SDK with your unique X-API-KEY. This is a required step before using other Purchasely functionalities. ```Swift Purchasely.start("<>") ``` -------------------------------- ### Retrieve User Attributes Source: https://github.com/purchasely/documentation/blob/v5.7/platform/react-native.md Get all user attributes or retrieve a specific attribute. For date attributes, parse the ISO string to get a Date object. ```typescript // Get all attributes const attributes = await Purchasely.userAttributes(); console.log(attributes); // Returns a PurchaselyUserAttribute object with key and value // Retrieve a specific attribute const dateAttribute = await Purchasely.userAttribute('subscription_date'); // For dates, parse the ISO 8601 string to retrieve the Date object console.log(new Date(dateAttribute).getFullYear()); ``` -------------------------------- ### Display Presentation in Swift Source: https://github.com/purchasely/documentation/blob/v5.7/custom_blocks/SDKDisplayMethodCodeSnipped.md Fetch and display an onboarding presentation. The source UIViewController is optional. ```Swift Purchasely.fetchPresentation(for: "onboarding", fetchCompletion: { presentation, error in guard error == nil, let presentation = presentation else { return } // Calling display() to launch the flow // Source UIViewController is optional presentation.display(from: myUIViewController) }) // If for some specific configuration you need to check if the presentation is a flow, that's possible but it should only be done if required by your implementation if presentation.isFlow { // presentation is a flow presentation.display() } ``` -------------------------------- ### Example Server Event Payload for Airship Source: https://github.com/purchasely/documentation/blob/v5.7/docs/🔌 Integrations/engagement-crm/airship.md This is an example JSON payload representing a purchase event that can be sent from Purchasely to Airship. It includes details about the purchase and the user. ```json { "body": { "name": "purchase_validated_server", "properties": { "application_name": "Purchasely", "application_package_id": "com.purchasely", "application_platform": "IOS", "plan_id": "PURCHASELY_PLUS_MONTHLY", "plan_name": "Monthly", "plan_store_product_id": "com.purchasely.plus.monthly", "plan_type": "RENEWING_SUBSCRIPTION", "product_id": "PURCHASELY_PLUS", "product_name": "Purchasely +", "store": "APPLE_APP_STORE" } }, "occurred":"2021-03-24T17:15:01", "user":{ "named_user_id": "jg" } } ``` -------------------------------- ### Start SDK with User ID Source: https://github.com/purchasely/documentation/blob/v5.7/docs/🚀 Getting Started/general-quick-start-guide/general-user-identification.md Initialize the Purchasely SDK with an API key and a specific user ID. This is useful if the user is already logged in when the SDK starts. ```swift import Purchasely func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { Purchasely.start( withAPIKey: "<>", appUserId: "XYZ-123-ABC-456" // user ID logLevel: .debug ) {(success, error) in print(success) } return true } ``` ```kotlin import android.app.Application import io.purchasely.ext.Purchasely import io.purchasely.google.GoogleStore class YourApplication: Application() { override fun onCreate() { super.onCreate() Purchasely.Builder(applicationContext) .apiKey("<>") .userId("XYZ-123-ABC-456") // user ID .build() .start { isConfigured, error -> if(isConfigured) { // Purchasely setup is complete ) } } } ``` ```typescript ReactNative import Purchasely from 'react-native-purchasely'; // Everything is optional except apiKey and storeKit1 // Example with default values try { const configured = await Purchasely.start({ apiKey: '<>', logLevel: LogLevels.ERROR, // set to debug in development mode to see logs userId: "XYZ-123-ABC-456" // user ID }); } catch (e) { console.log("Purchasely SDK not configured properly"); } ``` ```typescript Flutter // Everything is optional except apiKey and storeKit1 // Example with default values bool configured = await Purchasely.start( apiKey: '<>', logLevel: PLYLogLevel.error, // set to debug in development mode to see logs userId: "XYZ-123-ABC-456" // user ID ); if (!configured) { print('Purchasely SDK not configured'); return; } ``` ```javascript Cordova /*** * @params String apiKey * @params StringArray stores : may be Google, Amazon and Huawei * @params String userId * @params Purchasley.LogLevel logLevel * @params Purchasely.RunningMode runningMode **/ Purchasely.startWithAPIKey( '<>', ['Google'], "XYZ-123-ABC-456", // user ID Purchasely.LogLevel.DEBUG ); ``` -------------------------------- ### Install Purchasely SDK for iOS using CocoaPods Source: https://context7.com/purchasely/documentation/llms.txt Add the 'Purchasely' pod to your project's Podfile for installation via CocoaPods. Alternatively, use the Swift Package Manager. ```bash # iOS — CocoaPods pod 'Purchasely' # or Swift Package Manager: https://github.com/Purchasely/Purchasely-iOS ``` -------------------------------- ### Initialize Purchasely SDK in Kotlin Source: https://github.com/purchasely/documentation/blob/v5.7/docs/🚀 Getting Started/general-quick-start-guide/general-sdk-initialization.md Use the `Purchasely.Builder` to configure and start the SDK with your API key, an optional user ID, and a callback for initialization status. This should be done in your Application class. ```kotlin import android.app.Application import io.purchasely.ext.Purchasely import io.purchasely.google.GoogleStore class YourApplication: Application() { override fun onCreate() { super.onCreate() Purchasely.Builder(applicationContext) .apiKey("<>") .userId(null) // optional if you already know your user id .build() .start { isConfigured, error -> if(isConfigured) { // Purchasely setup is complete ) } } } ``` -------------------------------- ### Usage Example: Set Custom Screen Provider (Kotlin) Source: https://github.com/purchasely/documentation/blob/v5.7/docs/✈️ GOING FURTHER/byos/byos-implementation.md Example of setting a custom screen provider in Kotlin, including an anonymous object implementation for handling specific presentation IDs. ```kotlin val customScreenProvider = CustomScreenProvider() Purchasely.setCustomScreenProvider(customScreenProvider) // OR using anonymous object implementation Purchasely.setCustomScreenProvider( object : PLYCustomScreenProvider { override fun onCustomScreenRequested(presentation: PLYPresentation): PLYCustomScreen? { return when(presentation.id) { "login" -> { // Custom Login View PLYCustomScreen.View(yourCustomLoginView) // Or Custom Login Fragment // PLYCustomScreen.Fragment(yourCustomLoginFragment()) } else -> { return null } } } } ) ``` -------------------------------- ### Show Multiple Paywall Placements with ContextSDK Source: https://github.com/purchasely/documentation/blob/v5.7/docs/🔌 Integrations/engagement-crm/contextsdk.md Demonstrates how to use ContextSDK to manage and present paywalls for different user scenarios like onboarding, post-action, and settings. It shows how to create contexts and present paywalls using the `presentPurchaselyPaywall` helper function. ```swift // During onboarding func showOnboardingPaywall() { let context = ContextManager.instantContext(flowName: "purchasely_onboarding", duration: 3) presentPurchaselyPaywall(placement: "onboarding", context: context) } // After completing a key action func showPostActionPaywall() { let context = ContextManager.instantContext(flowName: "purchasely_post_action", duration: 3) presentPurchaselyPaywall(placement: "post_action", context: context) } // In settings func showSettingsPaywall() { let context = ContextManager.instantContext(flowName: "purchasely_settings", duration: 3) presentPurchaselyPaywall(placement: "settings", context: context) } private func presentPurchaselyPaywall(placement: String, context: Context) { // Set the context as a Purchasely user attribute Purchasely.setUserAttribute(withBoolValue: context.shouldUpsell, forKey: "context_should_upsell") let paywallController = Purchasely.presentationController( for: placement, loaded: { [weak self] controller, success, error in if let controller = controller, success { self?.present(controller, animated: true) } else { context.log(.skipped) } }, completion: { result, _ in switch result { case .purchased: context.log(.positive) case .cancelled: context.log(.negative) case .restored: context.log(.skipped) @unknown default: context.log(.skipped) } } ) } ``` -------------------------------- ### cURL Example for User Deletion Request Source: https://github.com/purchasely/documentation/blob/v5.7/docs/👤 Users/user-deletion-request.md This example demonstrates how to send a user deletion request using cURL. It includes the necessary headers such as Content-Type, X-API-KEY, and Authorization, along with the JSON payload. ```shell curl --request POST \ --url https://s2s.purchasely.io/user_deletion_requests \ --header 'Authorization: 06d2310b2fd4576c7287a7be99e2450a12e0fc1f4d62b1f1ef54aa3a38836677' \ --header 'Content-Type: application/json' \ --header 'X-API-KEY: 00000000-1111-2222-3333-444444444444' \ --data '{"user_id":"12345"}' ``` -------------------------------- ### Initialize SDK for React Native Source: https://github.com/purchasely/documentation/blob/v5.7/recipes/sdk-implementation.md Use the startWithApiKey method to initialize the SDK. The API key needs to be provided. ```javascript Purchasely.startWithApiKey() ``` -------------------------------- ### User Deletion Request JSON Body Example Source: https://github.com/purchasely/documentation/blob/v5.7/docs/👤 Users/user-deletion-request.md This is an example of the JSON body required to initiate a user data deletion request. Ensure the 'user_id' field contains your internal identifier for the user. ```json { "user_id": "12345" } ``` -------------------------------- ### Set Up UI/SDK Event Listener Source: https://github.com/purchasely/documentation/blob/v5.7/platform/ios.md Implement the PLYEventDelegate to track user interactions with Purchasely screens. Forward events to your analytics platform. ```swift Purchasely.setEventDelegate(self) // Implement PLYEventDelegate extension YourClass: PLYEventDelegate { func eventTriggered(_ event: PLYEvent) { print("Event: \(event.name)") // Forward to your analytics platform yourAnalytics.track(event.name, properties: event.properties) } } ``` -------------------------------- ### Get User Subscriptions History (Unity) Source: https://github.com/purchasely/documentation/blob/v5.7/docs/👤 Users/user-subscriptions-history.md Initiates a request to get the user's subscription history. Requires a callback for success and a logging function for errors. Iterates through the returned subscription data. ```csharp private PurchaselyRuntime.Purchasely _purchasely; ... _purchasely.GetUserSubscriptionsHistory(OnGetSubscriptionsHistorySuccess, Log); ... private void OnGetSubscriptionsHistorySuccess(List subscriptionData) { Log("Get Subscriptions history succeed."); foreach (var subscription in subscriptionData) { Log($"Subscription ID: {subscription.id}"); var plan = subscription.plan; if (plan != null) LogPlan(plan); var product = subscription.product; if (product != null) LogProduct(product); } } ``` -------------------------------- ### Initialise SDK with Observer Mode Source: https://github.com/purchasely/documentation/blob/v5.7/docs/Onboarding/sdk_initialisation/sdk_initialisation_cordova_observer.md Use this method to start the Purchasely SDK in observer mode. Provide your API key, the stores to target, a user ID for association, the desired log level, and set the running mode to `paywallObserver`. ```javascript /** * @params String apiKey * @params StringArray stores : may be Google, Amazon and Huawei * @params String userId * @params Purchasley.LogLevel logLevel * @params Purchasely.RunningMode runningMode **/ Purchasely.startWithAPIKey( '<>', ['Google'], true, // true for StoreKit 1, false for StoreKit 2 null, // user id of user Purchasely.LogLevel.DEBUG, Purchasely.RunningMode.paywallObserver ); ``` -------------------------------- ### Start SDK in PaywallObserver Mode (Swift) Source: https://github.com/purchasely/documentation/blob/v5.7/docs/🚀 Getting Started/sdk-quick-start/sdk-initialization.md Initialize the SDK in paywallObserver mode for Swift applications. Ensure you have the Purchasely SDK imported. ```Swift import Purchasely func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { Purchasely.start( withAPIKey: "<>", runningMode: .paywallObserver ) {(success, error) in print(success) } return true } ``` -------------------------------- ### Google Play Store CSV Import Example Source: https://github.com/purchasely/documentation/blob/v5.7/docs/➡️ MIGRATING TO PURCHASELY/subscribers-base-import.md Example CSV format for importing Google Play Store subscriptions with Billing version 5 or later. The 'store_product_id' should follow the 'subscription_id:base_plan_id' format. ```csv identifier;store_product_id;user_id;is_unknown aaaNNNcccDDDeeeFFF;subscription_id:base_plan_id;1234;false 000111222333444555;subscription_id:base_plan_id;;true ``` -------------------------------- ### Apple App Store CSV Import Example Source: https://github.com/purchasely/documentation/blob/v5.7/docs/➡️ MIGRATING TO PURCHASELY/subscribers-base-import.md Example CSV format for importing Apple App Store subscriptions using StoreKit 2. Ensure 'identifier', 'user_id', and 'is_unknown' columns are correctly populated. ```csv identifier;user_id;is_unknown 310001721313211;1234;false 310001234567890;;true ``` -------------------------------- ### Initialize Purchasely SDK in Unity (C#) Source: https://github.com/purchasely/documentation/blob/v5.7/docs/🚀 Getting Started/sdk-quick-start/sdk-initialization.md Instantiate the `PurchaselyRuntime.Purchasely` class to initialize the SDK in your Unity project. Provide the user ID, StoreKit version, log level, running mode, and callback functions for initialization and events. ```csharp private PurchaselyRuntime.Purchasely _purchasely; _purchasely = new PurchaselyRuntime.Purchasely("USER_ID", false, // true for StoreKit 1, false for StoreKit 2 LogLevel.Debug, RunningMode.Full, OnPurchaselyStart, OnPurchaselyEvent); ``` -------------------------------- ### User Deletion Request Response Examples Source: https://github.com/purchasely/documentation/blob/v5.7/docs/👤 Users/user-deletion-request.md These examples show the expected JSON responses for a successful deletion request (200) and common error scenarios (401, 400). The success response includes a deletion request identifier. ```json { "id": "00001111-2222-3333-4444-555566667777" } ``` ```json { "errors": ["Missing signature"] } ``` ```json { "errors": ["user_id is missing"] } ``` -------------------------------- ### Initialize Purchasely SDK in Flutter Source: https://context7.com/purchasely/documentation/llms.txt Call `Purchasely.start()` with necessary parameters like API key, Android stores, StoreKit version, log level, running mode, and user ID. Throws an exception if initialization fails. ```dart import 'package:purchasely_flutter/purchasely_flutter.dart'; bool configured = await Purchasely.start( apiKey: 'YOUR_API_KEY', androidStores: ['Google'], // requires purchasely_google package storeKit1: false, logLevel: PLYLogLevel.error, // PLYLogLevel.debug in development runningMode: PLYRunningMode.full, // PLYRunningMode.paywallObserver userId: null, ); if (!configured) throw Exception('SDK init failed'); ```