{"id":21478239,"url":"https://github.com/appsflyersdk/xamariniosbinding","last_synced_at":"2025-07-15T10:34:03.780Z","repository":{"id":33876115,"uuid":"37585866","full_name":"AppsFlyerSDK/XamariniOSBinding","owner":"AppsFlyerSDK","description":"AppsFlyer Xamarin iOS Binding project + example app","archived":false,"fork":false,"pushed_at":"2024-03-14T09:28:32.000Z","size":410146,"stargazers_count":8,"open_issues_count":2,"forks_count":7,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-11-13T04:11:07.837Z","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":"artyom/mtab","license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AppsFlyerSDK.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"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}},"created_at":"2015-06-17T09:31:01.000Z","updated_at":"2024-05-19T10:41:38.000Z","dependencies_parsed_at":"2024-03-10T16:35:13.719Z","dependency_job_id":null,"html_url":"https://github.com/AppsFlyerSDK/XamariniOSBinding","commit_stats":{"total_commits":101,"total_committers":13,"mean_commits":7.769230769230769,"dds":0.6336633663366337,"last_synced_commit":"8b5c132014182966789c7c7b7194d1aa27f90aaa"},"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AppsFlyerSDK%2FXamariniOSBinding","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AppsFlyerSDK%2FXamariniOSBinding/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AppsFlyerSDK%2FXamariniOSBinding/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AppsFlyerSDK%2FXamariniOSBinding/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AppsFlyerSDK","download_url":"https://codeload.github.com/AppsFlyerSDK/XamariniOSBinding/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226033199,"owners_count":17563127,"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:23.735Z","updated_at":"2025-07-15T10:34:03.759Z","avatar_url":"https://github.com/AppsFlyerSDK.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Xamarin iOS Binding\n\nXamarin Binding integration guide For iOS \n\nAppsFlyer Xamarin Binding version `v6.17.0` \u003cbr\u003e\nBuilt with AppsFlyer iOS SDK `v6.17.0`\n\n## ❗ v6 Breaking Changes\n\nUpgraded to .NET 8.0\n    \n# Overview\n    \nAppsFlyer SDK provides app installation and event logging functionality. We have developed an SDK that is highly robust (7+ billion SDK installations to date), secure, lightweight and very simple to embed.\n    \n    \n    \nYou can measure installs, updates and sessions and also log additional in-app events beyond app installs (including in-app purchases, game levels, etc.) to evaluate ROI and user engagement levels.\n    \n---\nAppsFlyer’s Xamarin binding provides application installation and events logging functionality.\n    \nThe API for the binding coincides with the native iOS API, which can be found [here](https://support.appsflyer.com/hc/en-us/articles/207032066-AppsFlyer-SDK-Integration-iOS).\n\n    \n\n## Table of content\n\n- [Nuget](#nuget_install)\n- [Quick Start](#quickStart)\n- [API Methods](#api-methods)\n    -  [SDK Initialization](#sdk_init)\n    -  [Logging In-App Events](#adding_events)\n    -  [Get Conversion Data](#conversion_data)\n    -  [Stop](#Stop)\n    -  [validateAndLogV2](#validateAndLogV2)\n    -  [logAdRevenue](#logAdRevenue)\n- [Sample App](#sample_app)\n\n\n\n# Nuget\nInstall-Package AppsFlyerXamarinBinding \u003cbr\u003e\nhttps://www.nuget.org/packages/AppsFlyerXamarinBinding\n\n\n\n# Quick Start\n\n\n\n#### Adding the Plugin to your Project\n\n    1. Go to Project \u003e Add NuGet Packages...\n    2. Select the AppsFlyerXamarinBinding\n    3. Select under version -  6.9.2\n    4. Click `Add Package`\n\n\n\n--------\n\nTo Embed SDK into your Application Manually:\n\n    1. Copy AppsFlyerXamarinBinding.dll into your project.\n    2. On Xamarin Studio go to References and click on Edit References.\n    3. Go to .Net Assembly tab and click on Browse… button.\n    4. Locate AppsFlyerXamarinBinding.dll and chose it.\n\n\n\n# API Methods\n\n\n\n##  SDK Initialization\n\n\n\nGo to your AppDelegate.cs and add:\n\n1) `using AppsFlyerXamarinBinding;` at the top of the file.\n\n\n2) Add the following code to the FinishedLaunching() method:\n\n```c#\npublic override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)\n{           \n    AppsFlyerLib.Shared.AppleAppID = \"\u003cAPP_ID\u003e\";\n    AppsFlyerLib.Shared.AppsFlyerDevKey = \"\u003cYOUR_DEV_KEY\u003e\";\n    /* AppsFlyerLib.Shared.Delegate = af_delegate; */\n    /* AppsFlyerLib.Shared.IsDebug = true; */\n  \n\n    return true;\n}\n```\n\n3) Add the following code in the OnActivated method:\n```c#\npublic override void OnActivated(UIApplication application)\n{\n    AppsFlyerLib.Shared.Start();\n}\n```\n\n\n\n## Logging In-App Events\n\nLogging in-app events is performed by calling `LogEvent` with event name and value parameters. See [In-App Events](https://support.appsflyer.com/hc/en-us/articles/115005544169-AppsFlyer-Rich-In-App-Events-Android-and-iOS) documentation for more details.\n\nEvent Example:\n```c#\nvar addToCartEvent = new NSDictionary(AFEventParameter.AFEventParamContentId, \"id 1\",\n                                      AFEventParameter.AFEventParamContentType, \"type 1\", \n                                      AFEventParameter.AFEventParamCurrency, \"USD\", \n                                      AFEventParameter.AFEventParamDescription, \"description\");\n\nAppsFlyerLib.Shared.LogEvent(AFEventName.AFEventAddToCart, addToCartEvent);\n```\n\n##  Get Conversion Data\n\n\nFirst add to the class-level declarations:\n```c#\nAppsFlyerLibDelegate af_delegate = new AppsFlyerConversionDataDelegate();\n```\n\nThen set up the delegate in FinishedLaunching:\n```c#\nAppsFlyerLib.Shared.Delegate = af_delegate;\n```\n\nAppsFlyerConversionDataDelegate.cs can be found here:\n\n```c#\npublic class AppsFlyerConversionDataDelegate : AppsFlyerLibDelegate\n{\n    public override void OnAppOpenAttribution(NSDictionary attributionData)\n    {\n        Console.WriteLine(\"deeplink data in xamarin = \" + attributionData.Description);\n    }\n    \n    public override void OnAppOpenAttributionFailure(NSError error) { }\n    \n    public override void OnConversionDataSuccess(NSDictionary conversionInfo)\n    {\n        Console.WriteLine(\"conversion data in xamarin = \" + installData.Description);\n    }\n    \n    public override void OnConversionDataFail(NSError error) { }\n}\n```\n\n##  Opt-Out\nFor complete opt out of the SDK use the following method call \n```c#\nAppsFlyerLib.Shared.IsStopped = true;\n```\nThis will prevent any data from being sent out of the AppsFlyer SDK.\n\n##  User invite\nAllowing your existing users to invite their friends and contacts as new users to your app can be a key growth factor for your app. AppsFlyer allows you to attribute and record new installs originating from user invites within your app.\nSet the OneLink ID, before calling Start(). \n```c#\nAppsFlyerLib.Shared.AppInviteOneLinkID = \"\u003cOneLinKID\u003e\";\n```\n\n```c#\nAppsFlyerXamarinBinding.AppsFlyerShareInviteHelper.generateInviteUrlWithLinkGenerator ((linkGenerator) =\u003e {\n        linkGenerator.setChannel (\"channel_name\");\n        linkGenerator.setReferrerName (\"ref_name\");\n        return linkGenerator;\n    }, completionHandler: (NSURL) =\u003e {\n        Console.WriteLine (NSURL);\n    }\n);\n```\n\n##  DMA consent\nAs part of the EU Digital Marketing Act (DMA) legislation, big tech companies must get consent from European end users before using personal data from third-party services for advertising.\u003cbr\u003e\nMore information [here](https://dev.appsflyer.com/hc/docs/send-consent-for-dma-compliance)\n\nThe SDK offers two alternative methods for gathering consent data:\u003cbr\u003e\n1. Through a Consent Management Platform (CMP): If the app uses a CMP that complies with the Transparency and Consent Framework (TCF) v2.2 protocol, the SDK can automatically retrieve the consent details.\n\nOR\n\n2. Through a dedicated SDK API: Developers can pass Google's required consent data directly to the SDK using a specific API designed for this purpose.\n\n### Use CMP to collect consent data\n1. Call `AppsFlyerLib.Shared.EnableTCFDataCollection(true);` before calling start()\n```c#\nAppsFlyerLib.Shared.EnableTCFDataCollection(true);\n```\n2. call start() **only after** the user approve the cmp consent pop up\n\nFull example:\n```c#\n[Export(\"application:didFinishLaunchingWithOptions:\")]\n    public bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)\n    {\n        AppsFlyerLib.Shared.AppleAppID = \"xXxXxX\";\n        AppsFlyerLib.Shared.AppsFlyerDevKey = \"xXxXxX\";\n        AppsFlyerLib.Shared.EnableTCFDataCollection(true);\n        return true;\n    }\n\n[Export(\"applicationDidBecomeActive:\")]\n    public void OnActivated(UIApplication application)\n    {\n        if (cmpManager.hasConsent()){\n            AppsFlyerLib.Shared.Start();\n        }\n    }\n```\nNote: `cmpManager` is here just for the example. use your own CMP.\n\n### Manually collect consent data\nIf your app does not use a CMP compatible with TCF v2.2, use the SDK API detailed below to provide the consent data directly to the SDK.\n\n#### When GDPR applies to the user\n1. Given that GDPR is applicable to the user, determine whether the consent data is already stored for this session.\n    1. If there is no consent data stored, show the consent dialog to capture the user consent decision.\n    2. If there is consent data stored continue to the next step.\n2. To transfer the consent data to the SDK create an AppsFlyerConsent object using forGDPRUser method that accepts the following parameters:\n    1. `hasConsentForDataUsage`: boolean - Indicates whether the user has consented to use their data for advertising purposes.\n    2. `hasConsentForAdsPersonalization: boolean` - Indicates whether the user has consented to use their data for personalized advertising.\n4. Call `AppsFlyerLib.Shared.SetConsentData(consent);` with the AppsFlyerConsent object.\n5. Call `AppsFlyerLib.Shared.Start();`\n\nFull example:\n```c#\n[Export(\"application:didFinishLaunchingWithOptions:\")]\n    public bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)\n    {\n        AppsFlyerLib.Shared.AppleAppID = \"xXxXxX\";\n        AppsFlyerLib.Shared.AppsFlyerDevKey = \"xXxXxX\";\n        AppsFlyerConsent consent = new AppsFlyerConsent().initForGDPRUser(true, true);\n        AppsFlyerLib.Shared.SetConsentData(consent);\n        return true;\n    }\n\n[Export(\"applicationDidBecomeActive:\")]\n    public void OnActivated(UIApplication application)\n    {\n        AppsFlyerLib.Shared.Start();\n    }\n```\n#### When GDPR does not apply to the user\n1. Create an AppsFlyerConsent object using forNonGDPRUser method that doesn't accepts any parameters\n2. Call `AppsFlyerLib.Shared.SetConsentData(consent);` with the AppsFlyerConsent object.\n3. Call `AppsFlyerLib.Shared.Start();`\n\nFull example:\n```c#\n[Export(\"application:didFinishLaunchingWithOptions:\")]\n    public bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)\n    {\n        AppsFlyerLib.Shared.AppleAppID = \"xXxXxX\";\n        AppsFlyerLib.Shared.AppsFlyerDevKey = \"xXxXxX\";\n        AppsFlyerConsent consent = new AppsFlyerConsent().initNonGDPRUser();\n        // AppsFlyerConsent consent = new AppsFlyerConsent().InitWithConsentData(null, null, true, false);\n        AppsFlyerLib.Shared.SetConsentData(consent);\n        return true;\n    }\n\n[Export(\"applicationDidBecomeActive:\")]\n    public void OnActivated(UIApplication application)\n    {\n        AppsFlyerLib.Shared.Start();\n    }\n```\n\n#### New API with all the freedom needed to decide id the user is `SubjectToGDPR`, `hasConsentForDataUsage`, `hasConsentForAdsPersonalization`, `hasConsentForAdStorage`:\n* call the following method: \n```c#\n AppsFlyerConsent InitWithConsentInfo(\n            bool? isUserSubjectToGDPR,\n            bool? hasConsentForDataUsage,\n            bool? hasConsentForAdsPersonalization,\n            bool? hasConsentForAdStorage)\n```            \n\nUse it this way:            \n\n```c#\n[Export(\"application:didFinishLaunchingWithOptions:\")]\n    public bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)\n    {\n        AppsFlyerLib.Shared.AppleAppID = \"xXxXxX\";\n        AppsFlyerLib.Shared.AppsFlyerDevKey = \"xXxXxX\";\n        AppsFlyerConsent consent = new AppsFlyerConsent().InitWithConsentData(null, null, true, false);\n        // Example to use this partial API.\n        // AppsFlyerConsent consent = new AppsFlyerConsent().InitWithConsentData(hasConsentForAdStorage: true);\n        AppsFlyerLib.Shared.SetConsentData(consent);\n        return true;\n    }\n\n[Export(\"applicationDidBecomeActive:\")]\n    public void OnActivated(UIApplication application)\n    {\n        AppsFlyerLib.Shared.Start();\n    }\n```\n\n\n## ValidateAndLogV2\n[Here](https://dev.appsflyer.com/hc/docs/validate-and-log-purchase-ios) you can find the info on what is the ValidateAndLog API purpose.\n```c#\nAFSDKPurchaseDetails details = new AFSDKPurchaseDetails(\"1234\", \"4.0\", \"USD\", \"123456789\");\nAppsFlyerLib.Shared.ValidateAndLogInAppPurchase(details, dictionary, (dict) =\u003e\n{\n    Console.WriteLine(dict.Description);\n    Console.WriteLine(dict.status);\n    Console.WriteLine(dict.error.Description);\n});\n```\n\n## LogAdRevenue\n[Here](https://dev.appsflyer.com/hc/docs/ad-revenue-2) you can find the info on what is the LogAdRevenue API purpose.\n```c#\nAFAdRevenueData adRevenueData = new AFAdRevenueData(\"ironsource\", AppsFlyerAdRevenueMediationNetworkType.Admost, \"USD\", 23.3);\nAppsFlyerLib.Shared.LogAdRevenue(adRevenueData, dictionary);\n```\n\n## Sample App \nSample apps for `xamarin.ios10` and `net6.0-ios` can be found here:\n```\nXamariniOSBinding/samples\n```\n\n\n---\n\nIn order for us to provide optimal support, we would kindly ask you to submit any issues to support@appsflyer.com.\n\n\n\n*_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\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fappsflyersdk%2Fxamariniosbinding","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fappsflyersdk%2Fxamariniosbinding","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fappsflyersdk%2Fxamariniosbinding/lists"}