Oscore.AppsFlyer.Maui
1.1.0
Prefix Reserved
dotnet add package Oscore.AppsFlyer.Maui --version 1.1.0
NuGet\Install-Package Oscore.AppsFlyer.Maui -Version 1.1.0
<PackageReference Include="Oscore.AppsFlyer.Maui" Version="1.1.0" />
paket add Oscore.AppsFlyer.Maui --version 1.1.0
#r "nuget: Oscore.AppsFlyer.Maui, 1.1.0"
// Install Oscore.AppsFlyer.Maui as a Cake Addin #addin nuget:?package=Oscore.AppsFlyer.Maui&version=1.1.0 // Install Oscore.AppsFlyer.Maui as a Cake Tool #tool nuget:?package=Oscore.AppsFlyer.Maui&version=1.1.0
AppsFlyer.Maui
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}");
};
Universal Links
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
ublic partial class App : Application
{
private readonly IAppsFlyer _appsFlyer;
private Uri? _deferredUniversalLink;
public App(IAppsFlyer appsFlyer)
{
_appsFlyer = appsFlyer;
InitializeComponent();
MainPage = new AppShell();
_appsFlyer.Started += OnAppsFlyerStarted;
}
protected override void OnAppLinkRequestReceived(Uri uri)
{
base.OnAppLinkRequestReceived(uri);
_deferredUniversalLink = uri;
}
private void OnAppsFlyerStarted(object? sender, EventArgs e)
{
if (_deferredUniversalLink != null &&
_deferredUniversalLink.AbsoluteUri.Contains("onelink"))
{
_appsFlyer.PerformOnAppAttribution(_deferredUniversalLink);
}
}
}
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.
Links
- https://github.com/AppsFlyerSDK/XamariniOSBinding
- https://github.com/AppsFlyerSDK/XamariniOSBinding/blob/master/samples/Sample.NuGet.Xamarin/AppDelegate.cs
- https://github.com/AppsFlyerSDK/XamarinAndroidBinding
- https://github.com/AppsFlyerSDK/appsflyer-MAUI-sample-app
- https://github.com/HavenDV/AppsFlyerSDK.Maui
- https://support.appsflyer.com/hc/en-us/articles/207031996-Registering-test-devices
- https://dev.appsflyer.com/hc/docs/testing-android#creating-an-android-debug-app
- https://dev.appsflyer.com/hc/docs/dl_android_unified_deep_linking
- https://dev.appsflyer.com/hc/docs/dl_android_ocds_ddl
- https://github.com/Redth/MAUI.AppLinks.Sample
- https://learn.microsoft.com/en-us/dotnet/maui/macios/universal-links
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net9.0 is compatible. net9.0-android35.0 is compatible. net9.0-ios18.0 is compatible. net9.0-maccatalyst18.0 is compatible. net9.0-windows10.0.19041 is compatible. |
-
net9.0
- Microsoft.Maui.Controls (>= 9.0.0)
-
net9.0-android35.0
- AppsFlyerXamarinBindingAndroid (>= 6.12.2)
- Microsoft.Maui.Controls (>= 9.0.0)
-
net9.0-ios18.0
- AppsFlyerXamarinBinding (>= 6.12.1)
- Microsoft.Maui.Controls (>= 9.0.0)
-
net9.0-maccatalyst18.0
- Microsoft.Maui.Controls (>= 9.0.0)
-
net9.0-windows10.0.19041
- Microsoft.Maui.Controls (>= 9.0.0)
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.1.0 | 252 | 12/5/2024 |
1.0.3 | 273 | 10/28/2024 |
1.0.2 | 351 | 9/5/2024 |
1.0.0 | 119 | 9/4/2024 |
0.9.22 | 140 | 8/21/2024 |
0.9.21 | 988 | 6/28/2024 |
0.9.20 | 111 | 6/28/2024 |
0.9.19 | 114 | 6/28/2024 |
0.9.18 | 117 | 6/28/2024 |
0.9.17 | 107 | 6/28/2024 |
0.9.16 | 107 | 6/28/2024 |
0.9.15 | 119 | 6/21/2024 |
0.9.14 | 127 | 6/20/2024 |
0.9.13 | 161 | 5/24/2024 |
0.9.12 | 139 | 5/23/2024 |
0.9.11 | 135 | 5/22/2024 |
0.9.10 | 118 | 5/21/2024 |
0.9.9 | 130 | 5/20/2024 |
0.9.8 | 162 | 5/6/2024 |
0.9.7 | 115 | 5/1/2024 |
0.9.6 | 93 | 5/1/2024 |
0.9.5 | 96 | 5/1/2024 |
0.9.4 | 120 | 5/1/2024 |
0.9.3 | 118 | 4/30/2024 |
0.9.2 | 110 | 4/30/2024 |
0.9.1 | 109 | 4/30/2024 |
0.9.0 | 114 | 4/17/2024 |
0.0.0-dev | 91 | 9/4/2024 |