AppsFlyerXamarinBinding 6.13.1

dotnet add package AppsFlyerXamarinBinding --version 6.13.1
NuGet\Install-Package AppsFlyerXamarinBinding -Version 6.13.1
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.13.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add AppsFlyerXamarinBinding --version 6.13.1
#r "nuget: AppsFlyerXamarinBinding, 6.13.1"
#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.
// Install AppsFlyerXamarinBinding as a Cake Addin
#addin nuget:?package=AppsFlyerXamarinBinding&version=6.13.1

// Install AppsFlyerXamarinBinding as a Cake Tool
#tool nuget:?package=AppsFlyerXamarinBinding&version=6.13.1

Xamarin iOS Binding

Xamarin Binding integration guide For iOS

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

❗ v6 Breaking Changes

We have renamed some of the APIs. For more details, please check out our Help Center

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();
        AppsFlyerLib.Shared.SetConsentData(consent);
        return true;
    }

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

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 net6.0-ios16.1 is compatible.  net7.0-ios was computed.  net8.0-ios was computed. 
Xamarin.iOS xamarinios10 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on AppsFlyerXamarinBinding:

Package Downloads
Oscore.AppsFlyer.Maui The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org.

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.13.1 262 3/14/2024
6.12.1 8,351 9/5/2023
6.10.1 9,829 4/11/2023
6.9.3-beta1 1,145 2/9/2023
6.9.2 2,840 2/9/2023
6.9.2-beta1 1,047 2/9/2023
6.5.4 27,023 4/28/2022
6.4.0.3 28,306 10/24/2021
6.4.0.1 2,843 9/29/2021
6.3.2 55,574 6/29/2021
6.3.0 7,484 5/27/2021
6.2.6.1 16,021 4/29/2021
6.2.4.1 5,654 3/31/2021
6.2.4 4,869 3/21/2021
6.2.3 1,337 3/9/2021
6.2.1 4,575 2/16/2021
6.1.3.2 4,564 1/18/2021
6.1.3.1 862 1/14/2021
6.1.3 806 1/14/2021
6.1.1 7,330 11/22/2020
6.0.3 17,414 9/7/2020
6.0.2 911 9/3/2020
6.0.1.1-beta 691 8/25/2020
5.4.1 7,151 7/28/2020
5.2.0 10,190 5/7/2020
1.3.5 26,433 9/16/2019
1.3.4 30,136 5/24/2018
1.3.3 9,275 12/18/2017
1.3.2 8,305 7/26/2017
1.3.1 4,735 2/27/2017
1.3.0 2,522 12/7/2016