Oscore.AppsFlyer.Maui 1.0.0

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package Oscore.AppsFlyer.Maui --version 1.0.0                
NuGet\Install-Package Oscore.AppsFlyer.Maui -Version 1.0.0                
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="Oscore.AppsFlyer.Maui" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Oscore.AppsFlyer.Maui --version 1.0.0                
#r "nuget: Oscore.AppsFlyer.Maui, 1.0.0"                
#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 Oscore.AppsFlyer.Maui as a Cake Addin
#addin nuget:?package=Oscore.AppsFlyer.Maui&version=1.0.0

// Install Oscore.AppsFlyer.Maui as a Cake Tool
#tool nuget:?package=Oscore.AppsFlyer.Maui&version=1.0.0                

AppsFlyer.Maui

Nuget package CI/CD License: MIT

Professional integration of existing Xamarin binding libraries in a single cross-platform interface according to best practices. This library implements deferred deep linking and extended deferred deep linking without additional configuration.

Usage

  • Add NuGet package to your project:
<PackageReference Include="Oscore.AppsFlyer.Maui" Version="1.0.0" />
  • Add the following to your MauiProgram.cs CreateMauiApp method:
builder
    .UseMauiApp<App>()
+   .UseAppsFlyer(options =>
+   {
+       options.DeveloperKey = "YOUR_DEVELOPER_KEY"; // Replace with your DevKey
+       options.AppleApplicationId = "YOUR_APPLE_APP_ID"; // Replace with your Apple AppId
+   })
    .ConfigureFonts(fonts =>
    {
        fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
        fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
    });
  • iOS: Add "NSUserTrackingUsageDescription" to your Info.plist file:
	<key>NSUserTrackingUsageDescription</key>
	<string>We use this data to improve user experience</string>
  • Use the following code to track events:
AppsFlyer.Current.LogEvent(Events.Purchase, new Dictionary<string, string>
{
    [EventParameters.Price] = "2",
    [EventParameters.Currency] = "USD",
    [EventParameters.Quantity] = "1",
    [EventParameters.Description] = "Description",
});
  • Use the following code to handle deep links:
AppsFlyer.Current.DeepLinkResolved += (sender, args) =>
{
    Console.WriteLine($"Deep link resolved: {args.Url}");
};

First, you need to set up your app to handle Universal links.
This is a way for your app to be opened by a URL, and potentially receive some data from that URL.
This is useful for things like sharing links to content in your app, or for handling links from marketing campaigns.

// MauiProgram.cs
builder
    .UseMauiApp<App>()
    .UseAppsFlyer()
+   .HandleUniversalLinks() // Only required if you don't use your own Universal link handling
    .ConfigureFonts(fonts =>
    {
        fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
        fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
    });
// App.xaml.cs
public partial class App : Application
{
    private readonly IAppsFlyer _appsFlyer;
    
    public App(IAppsFlyer appsFlyer)
    {
        _appsFlyer = appsFlyer;
        
        InitializeComponent();

		MainPage = new AppShell();
    }
    
    protected override void OnAppLinkRequestReceived(Uri uri)
    {
        base.OnAppLinkRequestReceived(uri);
 
        if (uri.AbsoluteUri.Contains("onelink"))
        {
            _appsFlyer.PerformOnAppAttributionAfterStart(uri);
        }
    }
}

Android

1. Check your .well-known Association file

https://your-project.onelink.me/.well-known/assetlinks.json should contain your app's package name.

2. Setup your Android Activity

You can reuse the Platforms/Android/MainActivity.cs in your MAUI app by adding the following class attribute to it:

[IntentFilter(
    new string[] { Intent.ActionView },
    AutoVerify = true,
    Categories = new[] { Intent.CategoryDefault, Intent.CategoryBrowsable },
    DataScheme = "https",
    DataHost = "your-project.onelink.me")]
[Activity(Exported = true, // other properties...)]

Note that you should use your own data scheme and host values. It's possible to associate multiple schemes/hosts here too.

3. Testing A URL

You can use adb to simulate opening a URL to ensure your app links work correctly:

adb shell am start -a android.intent.action.VIEW -c android.intent.category.BROWSABLE -d "https://your-project.onelink.me/Puun/2togg2t4"

iOS

1. Check your .well-known Association file

https://your-project.onelink.me/.well-known/apple-app-site-association should contain your app's bundle id and the associated domain(s).

2. Add Domain Association Entitlements to your App

You will need to add custom entitlements to your app to declare the associated domain(s).
You can do this either by adding an Entitlements.plist file to your app, or you can simply add the following to your .csproj file in your MAUI app:

<ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios' Or $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">

    
    <CustomEntitlements
        Condition="$(Configuration) == 'Debug'"
        Include="com.apple.developer.associated-domains"
        Type="StringArray"
        Value="applinks:your-project.onelink.me?mode=developer" />

    
    <CustomEntitlements
        Condition="$(Configuration) != 'Debug'"
        Include="com.apple.developer.associated-domains"
        Type="StringArray"
        Value="applinks:your-project.onelink.me" />

</ItemGroup>

Be sure to replace the applinks:your-project.onelink.me with the correct value for your own domain.
Also notice the ItemGroup's Condition which only includes the entitlement when the app is built for iOS or MacCatalyst.

3. Testing a URL

Testing on iOS can be a bit more tedious than Android.
It seems many have mixed results with iOS Simulators working (I was not able to get the Simulator working), so a device may be required, but is at least recommended.

Once you've deployed your app to your device, you can test that everything is setup correctly by going to Settings -> Developer and under Universal Links, toggle on Associated Domains Development and then go into Diagnostics.
Here you can enter your URL (in this case https://your-project.onelink.me/Puun/2togg2t4) and if everything is setup correctly you should see a green checkmark with Opens Installed Application and the App ID of your app.

It's also worth noting again that from step 2, if you add the applink entitlement with ?mode=developer to your app, it will bypass Apple's CDN cache when testing/debugging, which is helpful for iterating on your apple-app-site-association json file.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-android34.0 is compatible.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-ios17.5 is compatible.  net8.0-maccatalyst was computed.  net8.0-maccatalyst17.5 is compatible.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net8.0-windows10.0.19041 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.3 179 10/28/2024
1.0.2 344 9/5/2024
1.0.0 112 9/4/2024
0.9.22 133 8/21/2024
0.9.21 887 6/28/2024
0.9.20 104 6/28/2024
0.9.19 105 6/28/2024
0.9.18 108 6/28/2024
0.9.17 100 6/28/2024
0.9.16 98 6/28/2024
0.9.15 110 6/21/2024
0.9.14 120 6/20/2024
0.9.13 152 5/24/2024
0.9.12 132 5/23/2024
0.9.11 128 5/22/2024
0.9.10 109 5/21/2024
0.9.9 121 5/20/2024
0.9.8 153 5/6/2024
0.9.7 108 5/1/2024
0.9.6 88 5/1/2024
0.9.5 87 5/1/2024
0.9.4 113 5/1/2024
0.9.3 113 4/30/2024
0.9.2 103 4/30/2024
0.9.1 102 4/30/2024
0.9.0 109 4/17/2024
0.0.0-dev 82 9/4/2024