AppsFlyerXamarinBinding 6.17.22

dotnet add package AppsFlyerXamarinBinding --version 6.17.22
                    
NuGet\Install-Package AppsFlyerXamarinBinding -Version 6.17.22
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AppsFlyerXamarinBinding" Version="6.17.22" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AppsFlyerXamarinBinding" Version="6.17.22" />
                    
Directory.Packages.props
<PackageReference Include="AppsFlyerXamarinBinding" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add AppsFlyerXamarinBinding --version 6.17.22
                    
#r "nuget: AppsFlyerXamarinBinding, 6.17.22"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package AppsFlyerXamarinBinding@6.17.22
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=AppsFlyerXamarinBinding&version=6.17.22
                    
Install as a Cake Addin
#tool nuget:?package=AppsFlyerXamarinBinding&version=6.17.22
                    
Install as a Cake Tool

Xamarin iOS Binding

Xamarin Binding integration guide For iOS

AppsFlyer Xamarin Binding version v6.17.2 <br> Built with AppsFlyer iOS SDK v6.17.2

❗ v6 Breaking Changes

Upgraded to .NET 8.0

⚠️ Breaking Changes in v6.17.2

ValidateAndLog API: Changed API parameters - now AFSDKPurchaseDetails only accepts productId, transactionId, and purchaseType (new enum). See implementation example for the new callback signature with response or error.

Overview

AppsFlyer 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.

You 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.


AppsFlyer’s Xamarin binding provides application installation and events logging functionality.

The API for the binding coincides with the native iOS API, which can be found here.

Table of content

Nuget

Install-Package AppsFlyerXamarinBinding <br> https://www.nuget.org/packages/AppsFlyerXamarinBinding

Quick Start

Adding the Plugin to your Project
1. Go to Project > Add NuGet Packages...
2. Select the AppsFlyerXamarinBinding
3. Select under version -  6.9.2
4. Click `Add Package`

To Embed SDK into your Application Manually:

1. Copy AppsFlyerXamarinBinding.dll into your project.
2. On Xamarin Studio go to References and click on Edit References.
3. Go to .Net Assembly tab and click on Browse… button.
4. Locate AppsFlyerXamarinBinding.dll and chose it.

API Methods

SDK Initialization

Go to your AppDelegate.cs and add:

  1. using AppsFlyerXamarinBinding; at the top of the file.

  2. Add the following code to the FinishedLaunching() method:

public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
{           
    AppsFlyerLib.Shared.AppleAppID = "<APP_ID>";
    AppsFlyerLib.Shared.AppsFlyerDevKey = "<YOUR_DEV_KEY>";
    /* AppsFlyerLib.Shared.Delegate = af_delegate; */
    /* AppsFlyerLib.Shared.IsDebug = true; */
  

    return true;
}
  1. Add the following code in the OnActivated method:
public override void OnActivated(UIApplication application)
{
    AppsFlyerLib.Shared.Start();
}

Logging In-App Events

Logging in-app events is performed by calling LogEvent with event name and value parameters. See In-App Events documentation for more details.

Event Example:

var addToCartEvent = new NSDictionary(AFEventParameter.AFEventParamContentId, "id 1",
                                      AFEventParameter.AFEventParamContentType, "type 1", 
                                      AFEventParameter.AFEventParamCurrency, "USD", 
                                      AFEventParameter.AFEventParamDescription, "description");

AppsFlyerLib.Shared.LogEvent(AFEventName.AFEventAddToCart, addToCartEvent);

Get Conversion Data

First add to the class-level declarations:

AppsFlyerLibDelegate af_delegate = new AppsFlyerConversionDataDelegate();

Then set up the delegate in FinishedLaunching:

AppsFlyerLib.Shared.Delegate = af_delegate;

AppsFlyerConversionDataDelegate.cs can be found here:

public class AppsFlyerConversionDataDelegate : AppsFlyerLibDelegate
{
    public override void OnAppOpenAttribution(NSDictionary attributionData)
    {
        Console.WriteLine("deeplink data in xamarin = " + attributionData.Description);
    }
    
    public override void OnAppOpenAttributionFailure(NSError error) { }
    
    public override void OnConversionDataSuccess(NSDictionary conversionInfo)
    {
        Console.WriteLine("conversion data in xamarin = " + installData.Description);
    }
    
    public override void OnConversionDataFail(NSError error) { }
}

Opt-Out

For complete opt out of the SDK use the following method call

AppsFlyerLib.Shared.IsStopped = true;

This will prevent any data from being sent out of the AppsFlyer SDK.

User invite

Allowing 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. Set the OneLink ID, before calling Start().

AppsFlyerLib.Shared.AppInviteOneLinkID = "<OneLinKID>";
AppsFlyerXamarinBinding.AppsFlyerShareInviteHelper.generateInviteUrlWithLinkGenerator ((linkGenerator) => {
        linkGenerator.setChannel ("channel_name");
        linkGenerator.setReferrerName ("ref_name");
        return linkGenerator;
    }, completionHandler: (NSURL) => {
        Console.WriteLine (NSURL);
    }
);

As 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.<br> More information here

The SDK offers two alternative methods for gathering consent data:<br>

  1. 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.

OR

  1. 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.
  1. Call AppsFlyerLib.Shared.EnableTCFDataCollection(true); before calling start()
AppsFlyerLib.Shared.EnableTCFDataCollection(true);
  1. call start() only after the user approve the cmp consent pop up

Full example:

[Export("application:didFinishLaunchingWithOptions:")]
    public bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
    {
        AppsFlyerLib.Shared.AppleAppID = "xXxXxX";
        AppsFlyerLib.Shared.AppsFlyerDevKey = "xXxXxX";
        AppsFlyerLib.Shared.EnableTCFDataCollection(true);
        return true;
    }

[Export("applicationDidBecomeActive:")]
    public void OnActivated(UIApplication application)
    {
        if (cmpManager.hasConsent()){
            AppsFlyerLib.Shared.Start();
        }
    }

Note: cmpManager is here just for the example. use your own CMP.

If 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.

When GDPR applies to the user
  1. Given that GDPR is applicable to the user, determine whether the consent data is already stored for this session.
    1. If there is no consent data stored, show the consent dialog to capture the user consent decision.
    2. If there is consent data stored continue to the next step.
  2. To transfer the consent data to the SDK create an AppsFlyerConsent object using forGDPRUser method that accepts the following parameters:
    1. hasConsentForDataUsage: boolean - Indicates whether the user has consented to use their data for advertising purposes.
    2. hasConsentForAdsPersonalization: boolean - Indicates whether the user has consented to use their data for personalized advertising.
  3. Call AppsFlyerLib.Shared.SetConsentData(consent); with the AppsFlyerConsent object.
  4. Call AppsFlyerLib.Shared.Start();

Full example:

[Export("application:didFinishLaunchingWithOptions:")]
    public bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
    {
        AppsFlyerLib.Shared.AppleAppID = "xXxXxX";
        AppsFlyerLib.Shared.AppsFlyerDevKey = "xXxXxX";
        AppsFlyerConsent consent = new AppsFlyerConsent().initForGDPRUser(true, true);
        AppsFlyerLib.Shared.SetConsentData(consent);
        return true;
    }

[Export("applicationDidBecomeActive:")]
    public void OnActivated(UIApplication application)
    {
        AppsFlyerLib.Shared.Start();
    }
When GDPR does not apply to the user
  1. Create an AppsFlyerConsent object using forNonGDPRUser method that doesn't accepts any parameters
  2. Call AppsFlyerLib.Shared.SetConsentData(consent); with the AppsFlyerConsent object.
  3. Call AppsFlyerLib.Shared.Start();

Full example:

[Export("application:didFinishLaunchingWithOptions:")]
    public bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
    {
        AppsFlyerLib.Shared.AppleAppID = "xXxXxX";
        AppsFlyerLib.Shared.AppsFlyerDevKey = "xXxXxX";
        AppsFlyerConsent consent = new AppsFlyerConsent().initNonGDPRUser();
        // AppsFlyerConsent consent = new AppsFlyerConsent().InitWithConsentData(null, null, true, false);
        AppsFlyerLib.Shared.SetConsentData(consent);
        return true;
    }

[Export("applicationDidBecomeActive:")]
    public void OnActivated(UIApplication application)
    {
        AppsFlyerLib.Shared.Start();
    }
New API with all the freedom needed to decide id the user is SubjectToGDPR, hasConsentForDataUsage, hasConsentForAdsPersonalization, hasConsentForAdStorage:
  • call the following method:
 AppsFlyerConsent InitWithConsentInfo(
            bool? isUserSubjectToGDPR,
            bool? hasConsentForDataUsage,
            bool? hasConsentForAdsPersonalization,
            bool? hasConsentForAdStorage)

Use it this way:

[Export("application:didFinishLaunchingWithOptions:")]
    public bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
    {
        AppsFlyerLib.Shared.AppleAppID = "xXxXxX";
        AppsFlyerLib.Shared.AppsFlyerDevKey = "xXxXxX";
        AppsFlyerConsent consent = new AppsFlyerConsent().InitWithConsentData(null, null, true, false);
        // Example to use this partial API.
        // AppsFlyerConsent consent = new AppsFlyerConsent().InitWithConsentData(hasConsentForAdStorage: true);
        AppsFlyerLib.Shared.SetConsentData(consent);
        return true;
    }

[Export("applicationDidBecomeActive:")]
    public void OnActivated(UIApplication application)
    {
        AppsFlyerLib.Shared.Start();
    }

ValidateAndLogV2

Here you can find the info on what is the ValidateAndLog API purpose.

AFSDKPurchaseType Enum

A new enum AFSDKPurchaseType is now used to specify the purchase type in the AFSDKPurchaseDetails constructor for the ValidateAndLog API. The available values are:

  • AFSDKPurchaseType.Subscription — for subscription-based purchases (e.g., monthly or yearly recurring payments).
  • AFSDKPurchaseType.OneTimePurchase — for one-time purchases (e.g., single in-app purchase, non-recurring).
AFSDKPurchaseDetails details = new AFSDKPurchaseDetails("1234", "123456789", AFSDKPurchaseType.OneTimePurchase);
AppsFlyerLib.Shared.ValidateAndLogInAppPurchase(details, dictionary, (response, error) =>
{
    if (error != null)
    {
        Console.WriteLine($"Error: {error.Description}");
        return;
    }
    
    Console.WriteLine($"Status: {response.Status}");
});

LogAdRevenue

Here you can find the info on what is the LogAdRevenue API purpose.

AFAdRevenueData adRevenueData = new AFAdRevenueData("ironsource", AppsFlyerAdRevenueMediationNetworkType.Admost, "USD", 23.3);
AppsFlyerLib.Shared.LogAdRevenue(adRevenueData, dictionary);

Sample App

Sample apps for xamarin.ios10 and net6.0-ios can be found here:

XamariniOSBinding/samples

In order for us to provide optimal support, we would kindly ask you to submit any issues to support@appsflyer.com.

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.

Product Compatible and additional computed target framework versions.
.NET net8.0-ios18.0 is compatible.  net9.0-ios was computed.  net10.0-ios was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0-ios18.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on AppsFlyerXamarinBinding:

Package Downloads
Oscore.AppsFlyer.Maui

Professional integration of existing Xamarin binding libraries in a single cross-platform interface according to best practices.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
6.17.22 214 8/14/2025
6.17.5 132 9/4/2025
6.17.3 235 8/25/2025
6.17.2 188 8/13/2025
6.17.0 2,015 5/5/2025
6.15.3 2,481 1/28/2025
6.13.1 16,778 3/14/2024
6.12.1 21,698 9/5/2023
6.10.1 17,720 4/11/2023
6.9.3-beta1 1,261 2/9/2023
6.9.2 3,132 2/9/2023
6.9.2-beta1 1,170 2/9/2023
6.5.4 28,963 4/28/2022
6.4.0.3 28,576 10/24/2021
6.4.0.1 2,959 9/29/2021
6.3.2 55,903 6/29/2021
6.3.0 7,634 5/27/2021
6.2.6.1 16,342 4/29/2021
6.2.4.1 5,935 3/31/2021
6.2.4 4,987 3/21/2021
6.2.3 1,470 3/9/2021
6.2.1 4,726 2/16/2021
6.1.3.2 4,699 1/18/2021
6.1.3.1 991 1/14/2021
6.1.3 931 1/14/2021
6.1.1 7,462 11/22/2020
6.0.3 17,542 9/7/2020
6.0.2 1,048 9/3/2020
6.0.1.1-beta 817 8/25/2020
5.4.1 7,286 7/28/2020
5.2.0 10,350 5/7/2020
1.3.5 26,613 9/16/2019
1.3.4 30,520 5/24/2018
1.3.3 9,547 12/18/2017
1.3.2 8,744 7/26/2017
1.3.1 5,483 2/27/2017
1.3.0 2,933 12/7/2016