{"id":21478222,"url":"https://github.com/appsflyersdk/appsflyer-apple-purchase-connector","last_synced_at":"2025-06-20T16:40:53.987Z","repository":{"id":40942386,"uuid":"412416602","full_name":"AppsFlyerSDK/appsflyer-apple-purchase-connector","owner":"AppsFlyerSDK","description":null,"archived":false,"fork":false,"pushed_at":"2025-06-05T09:09:04.000Z","size":28438,"stargazers_count":3,"open_issues_count":0,"forks_count":4,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-06-14T09:39:18.692Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AppsFlyerSDK.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-10-01T10:06:56.000Z","updated_at":"2025-06-05T09:09:06.000Z","dependencies_parsed_at":"2022-08-29T07:51:41.793Z","dependency_job_id":"feb0bbef-cd59-48c7-8634-af9143f243cc","html_url":"https://github.com/AppsFlyerSDK/appsflyer-apple-purchase-connector","commit_stats":null,"previous_names":["appsflyersdk/appsflyer-framework-ars-beta"],"tags_count":19,"template":false,"template_full_name":null,"purl":"pkg:github/AppsFlyerSDK/appsflyer-apple-purchase-connector","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AppsFlyerSDK%2Fappsflyer-apple-purchase-connector","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AppsFlyerSDK%2Fappsflyer-apple-purchase-connector/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AppsFlyerSDK%2Fappsflyer-apple-purchase-connector/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AppsFlyerSDK%2Fappsflyer-apple-purchase-connector/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AppsFlyerSDK","download_url":"https://codeload.github.com/AppsFlyerSDK/appsflyer-apple-purchase-connector/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AppsFlyerSDK%2Fappsflyer-apple-purchase-connector/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260980971,"owners_count":23092298,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-23T11:17:15.727Z","updated_at":"2025-06-20T16:40:48.972Z","avatar_url":"https://github.com/AppsFlyerSDK.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg src=\"https://massets.appsflyer.com/wp-content/uploads/2018/06/20092440/static-ziv_1TP.png\"  width=\"400\" \u003e \n\n# iOS Purchase Connector\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/AppsFlyerSDK/android-purchase-connector/blob/main/LICENSE)\n\n🛠 In order for us to provide optimal support, we would kindly ask you to submit any issues to\nsupport@appsflyer.com\n\n\u003e *When submitting an issue please specify your AppsFlyer sign-up (account) email , your app ID , production steps, logs, code snippets and any additional relevant information.\n\n## Table Of Content\n  * [This Module is Built for](#plugin-build-for)\n  * [Adding The Connector To Your Project](#install-connector)\n    + [Cocoapods](#cocoapods)\n    + [Carthage](#carthage)\n    + [SPM](#spm)\n  * [Basic Integration Of The Connector](#basic-integration)\n    + [Set up Purchase Connector](#create-instance)\n    + [Log Auto-Renewable Subscriptions and In-App Purchases](#log-subscriptions)\n    + [Conform to Purchase Connector Data Source and Delegate protocols](#conforming)\n    + [Start Observing Transactions](#start)\n    + [Stop Observing Transactions](#stop)\n  * [Testing the implementation in Sandbox](#testing)\n  * [Full Code Examples](#example)\n\n\n## \u003ca id=\"plugin-build-for\"\u003e This Module is Built for\n- StoreKit SDK v1.\n- iOS version 9 and higher.\n- iOS AppsFlyer SDK **6.8.0** and higher.\n\n\u003e *IMPORTNANT NOTE: Please, be sure to check Purchase Connector and AppsFlyerFramework version compatability table and use corresponding versions to avoid unexpected behaviour *\n\n|  PurchaseConnector  | AppsFlyerSDK |\n| :------: | :--------: |\n| 6.8.0    | 6.8.0 - 6.9.2 |\n| 6.8.1    | 6.8.0 - 6.9.2 |\n| 6.10.0   |  6.10.0 |\n| 6.10.1   |  6.10.1 |\n| 6.12.2   |  6.12.2 |\n| 6.12.3   |  6.12.2 |\n\n\n## \u003ca id=\"cocoapods\"\u003e  Adding The Connector To Your Project via Cocoapods: \nAdd to your Podfile and run `pod install`:\n```\n// for statically linked dependency\npod 'PurchaseConnector'\n\n// for dynamically linked dependency\npod 'PurchaseConnector/Dynamic'\n\n// for statically linked Strict dependency (disabled IDFA collection)\npod 'PurchaseConnector/Strict'\n```\n\n\n## \u003ca id=\"carthage\"\u003e  Adding The Connector To Your Project via Carthage: \nGo to the `Carthage` folder in the root of the repository. Open `purchase-connector-dynamic.json` or `purchase-connector-static.json`, click raw, copy and paste the URL of the file to your `Cartfile`: \n```\nbinary \"https://raw.githubusercontent.com/AppsFlyerSDK/appsflyer-apple-purchase-connector/main/Carthage/purchase-connector-dynamic.json\" == BIINARY_VERSION\nbinary \"https://raw.githubusercontent.com/AppsFlyerSDK/AppsFlyerFramework/master/Carthage/appsflyer-ios.json\" ~\u003e 6.10.0\n```\nThen open project folder in the terminal and use command `carthage update --use-xcframeworks`, then, drag and drop PurchaseConnector.xcframework binary and AppsFlyerLib.framework (from Carthage/Build/iOS folder).\n\nMore reference on Carthage binary artifacts integration [here](https://github.com/Carthage/Carthage/blob/master/Documentation/Artifacts.md).\n\n## \u003ca id=\"spm\"\u003e  Adding The Connector To Your Project via SPM: \nPlease, follow standard SPM dependency manager instructions.\n\n\u003e *Note: This repository contains statically linked `PurchaseConnector.xcframework`. If you want to use dynamic .xcframework, please integrate it for SPM from this repository:\nhttps://github.com/AppsFlyerSDK/PurchaseConnector-Dynamic* \n\n\u003e *Note: as PurchaseConnector has a dependency on [AppsFlyerLib framework](https://github.com/AppsFlyerSDK/AppsFlyerFramework), please, make sure to integrate it as well for Carthage and SPM.*\n\n## \u003ca id=\"basic-integration\"\u003e Basic Integration Of The Connector\n\u003e *Note: before the implementation of the Purchase connector, please make sure to set up AppsFlyer `appId` and `devKey`*\n\n### \u003ca id=\"create-instance\"\u003e Set up Purchase Connector\n- Swift \n```swift\n// Import the library\n    import AppsFlyerLib\n    import StoreKit\n    import PurchaseConnector\n\n// Default SDK Implementation\n    AppsFlyerLib.shared().appsFlyerDevKey = \"DEV_KEY\"\n    AppsFlyerLib.shared().appleAppID = \"APPLE_APP_ID\"\n    //AppsFlyerLib.shared().isDebug = true\n\n// Purchase connector implementation \n    PurchaseConnector.shared().purchaseRevenueDelegate = self\n    PurchaseConnector.shared().purchaseRevenueDataSource = self\n```\n\n- Objective-C \n```objective-c\n// Import the library\n    #import \"AppDelegate.h\"\n    #import \u003cAppsFlyerLib/AppsFLyerLib.h\u003e\n    #import \u003cPurchaseConnector/PurchaseConnector.h\u003e\n\n// Default SDK implementation\n    [[AppsFlyerLib shared] setAppleAppID:@\"APPLE_APP_ID\"];\n    [[AppsFlyerLib shared] setAppsFlyerDevKey:@\"DEV_KEY\"];\n    //[[AppsFlyerLib shared] setIsDebug:YES];\n\n// Purchase Connecor implementation\n    [[PurchaseConnector shared] setPurchaseRevenueDelegate:self];\n    [[PurchaseConnector shared] setPurchaseRevenueDataSource:self];\n```\n\n### \u003ca id=\"log-subscriptions\"\u003e Log Auto-Renewable Subscriptions and In-App Purchases\n\nEnables automatic logging of In-App purchases and Auto-renewable subscriptions.\n\n- Swift \n```swift\nPurchaseConnector.shared().autoLogPurchaseRevenue = [.autoRenewableSubscriptions, .inAppPurchases]\n```\n\n- Objective-C \n```objective-c\n[[PurchaseConnector shared] setAutoLogPurchaseRevenue:AFSDKAutoLogPurchaseRevenueOptionsRenewable | AFSDKAutoLogPurchaseRevenueOptionsInAppPurchases];\n```\n\n\u003e *Note: if `autoLogPurchaseRevenue` has not been set, it is disabled by default. The value is an option set, so you can choose what kind of user purchases you want to observe.*\n\n### \u003ca id=\"conforming\"\u003e Conform to Purchase Connector Data Source and Delegate protocols\n\n* In order to receive purchase validation event callbacks, you should conform to and implement `PurchaseRevenueDelegate`(Swift) or `AppsFlyerPurchaseRevenueDelegate`(Objc-C) protocol.\n* To be able to add your custom parameters to the purchase event, that Connector sends, please conform to  and implement `PurchaseRevenueDataSource`(Swift) or `AppsFlyerPurchaseRevenueDataSource`(Obj-C) protocol.\n\n- Swift \n```swift\nextension AppDelegate: PurchaseRevenueDataSource, PurchaseRevenueDelegate {\n    // PurchaseRevenueDelegate method implementation\n    func didReceivePurchaseRevenueValidationInfo(_ validationInfo: [AnyHashable : Any]?, error: Error?) {\n        print(\"PurchaseRevenueDelegate: \\(validationInfo)\")\n        print(\"PurchaseRevenueDelegate: \\(error)\")\n      // process validationInfo here \n}\n    // PurchaseRevenueDataSource method implementation\n    func purchaseRevenueAdditionalParameters(for products: Set\u003cSKProduct\u003e, transactions: Set\u003cSKPaymentTransaction\u003e?) -\u003e [AnyHashable : Any]? {\n        // Add additional parameters for SKTransactions here.\n        return [\"additionalParameters\":[\"param1\":\"value1\", \"param2\":\"value2\"]];\n    }\n}\n```\n\n- Objective-C \n```objective-c\n@interface AppDelegate () \u003cAppsFlyerPurchaseRevenueDelegate, AppsFlyerPurchaseRevenueDataSource\u003e\n@end\n\n@implementation AppDelegate\n\n- (void)applicationDidBecomeActive:(UIApplication *)application {\n    [[AppsFlyerLib shared] start];\n    [[PurchaseConnector shared] startObservingTransactions];\n}\n\n- (void)didReceivePurchaseRevenueValidationInfo:(NSDictionary *)validationInfo error:(NSError *)error {\n    NSLog(@\"Validation info: %@\", validationInfo);\n    NSLog(@\"Error: %@\", error);\n    \n    // Process validation info\n}\n\n- (NSDictionary *)purchaseRevenueAdditionalParametersForProducts:(NSSet\u003cSKProduct *\u003e *)products transactions:(NSSet\u003cSKPaymentTransaction *\u003e *)transactions {\n    return @{@\"key1\" : @\"param1\"};\n}\n\n@end\n```\n\n### \u003ca id=\"start\"\u003e Start Observing Transactions\n\n`startObservingTransactions` should be called to start observing transactions.\u003cbr\u003e\n \u003e *Note: This should be called right after the AppsFlyer iOS SDK's start method..*\n\n- Swift \n```swift\n    PurchaseConnector.shared().startObservingTransactions()\n```\n\n- Objective-C \n```objective-c\n    [[PurchaseConnector shared] startObservingTransactions];\n```\n\n### \u003ca id=\"stop\"\u003e Stop Observing Transactions\n\nTo stop observing transactions, you need to call `stopObservingTransactions`.\n\n- Swift \n```swift\n    PurchaseConnector.shared().stopObservingTransactions()\n```\n\n- Objective-C \n```objective-c\n    [[PurchaseConnector shared] stopObservingTransactions];\n```\n\n\u003e *Note: if you called `stopObservingTransactions` API, you should set `autoLogPurchaseRevenue` value before you call `startObservingTransactions` next time.*\n\n## \u003ca id=\"testing\"\u003e Testing the implementation in Sandbox\n\nIn order to test purchases in Xcode environment on a real device with TestFlight sandbox account, you need to set `isSandbox` to true.\n\n- Swift \n```swift\n    PurchaseConnector.shared().isSandbox = true\n```\n\n- Objective-C \n```objective-c\n    [[PurchaseConnector shared] setIsSandbox:YES];\n```\n\n\u003e *IMPORTANT NOTE: Before releasing your app to production please be sure to remove `isSandbox` or set it to `false`. If the production purchase event will be sent in sandbox mode, your event will not be validated properly! *\n\n***\n\n## \u003ca id=\"example\"\u003e Full Code Examples\n\n### Swift Example \n```swift\nimport AppsFlyerLib\nimport StoreKit\nimport PurchaseConnector\n\nclass AppDelegate: UIResponder, UIApplicationDelegate {\n   func application(_ _: UIApplication, didFinishLaunchingWithOptions _: [UIApplicationLaunchOptionsKey: Any]?) -\u003e Bool {\n    // Default SDK Implementation\n        AppsFlyerLib.shared().appsFlyerDevKey = \"DEV_KEY\"\n        AppsFlyerLib.shared().appleAppID = \"APLE_APP_ID\"\n        // AppsFlyerLib.shared().isDebug = true\n      \n   // Purchase Connector implementation\n        PurchaseConnector.shared().purchaseRevenueDelegate = self\n        PurchaseConnector.shared().purchaseRevenueDataSource = self\n        PurchaseConnector.shared().autoLogPurchaseRevenue = .autoRenewableSubscriptions\n   }\n\n   func applicationDidBecomeActive(_ application: UIApplication) {\n        AppsFlyerLib.shared().start()\n        PurchaseConnector.shared().startObservingTransactions()\n    }\n}\n\nextension AppDelegate: PurchaseRevenueDataSource, PurchaseRevenueDelegate {\n    // PurchaseRevenueDelegate method implementation\n    func didReceivePurchaseRevenueValidationInfo(_ validationInfo: [AnyHashable : Any]?, error: Error?) {\n        print(\"PurchaseRevenueDelegate: \\(validationInfo)\")\n        print(\"PurchaseRevenueDelegate: \\(error)\")\n      // process validationInfo here \n}\n    // PurchaseRevenueDataSource method implementation\n    func purchaseRevenueAdditionalParameters(for products: Set\u003cSKProduct\u003e, transactions: Set\u003cSKPaymentTransaction\u003e?) -\u003e [AnyHashable : Any]? {\n        // Add additional parameters for SKTransactions here.\n        return [\"additionalParameters\":[\"param1\":\"value1\", \"param2\":\"value2\"]];\n    }\n}\n```\n\n###  Objective-C Example \n```objective-c\n#import \"AppDelegate.h\"\n#import \u003cPurchaseConnector/PurchaseConnector.h\u003e\n#import \u003cAppsFlyerLib/AppsFLyerLib.h\u003e\n\n@interface AppDelegate () \u003cAppsFlyerPurchaseRevenueDelegate, AppsFlyerPurchaseRevenueDataSource\u003e\n\n@end\n\n@implementation AppDelegate\n\n\n- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {\n    \n    // Set up AppsFlyerLib first\n    [[AppsFlyerLib shared] setAppleAppID:@\"APPLE_APP_ID\"];\n    [[AppsFlyerLib shared] setAppsFlyerDevKey:@\"DEV_KEY\"];\n    // [[AppsFlyerLib shared] setIsDebug:YES];\n    \n    // Set up PurchaseConnector\n    [[PurchaseConnector shared] setPurchaseRevenueDelegate:self];\n    [[PurchaseConnector shared] setPurchaseRevenueDataSource:self];\n    [[PurchaseConnector shared] setAutoLogPurchaseRevenue:AFSDKAutoLogPurchaseRevenueOptionsAutoRenewableSubscriptions];\n    return YES;\n}\n\n- (void)applicationDidBecomeActive:(UIApplication *)application {\n     [[AppsFlyerLib shared] start];\n     [[PurchaseConnector shared] startObservingTransactions];\n}\n\n- (void)didReceivePurchaseRevenueValidationInfo:(NSDictionary *)validationInfo error:(NSError *)error {\n    NSLog(@\"Validation info: %@\", validationInfo);\n    NSLog(@\"Error: %@\", error);\n    \n    // Process validation info\n}\n\n- (NSDictionary *)purchaseRevenueAdditionalParametersForProducts:(NSSet\u003cSKProduct *\u003e *)products transactions:(NSSet\u003cSKPaymentTransaction *\u003e *)transactions {\n    return @{@\"key1\" : @\"param1\"};\n}\n\n@end\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fappsflyersdk%2Fappsflyer-apple-purchase-connector","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fappsflyersdk%2Fappsflyer-apple-purchase-connector","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fappsflyersdk%2Fappsflyer-apple-purchase-connector/lists"}