.NET MAUI / Xamarin SDK
The Datafly Signal .NET MAUI SDK wraps the native iOS and Android SDKs, providing a C# API for .NET MAUI and Xamarin.Forms applications.
Requirements
- .NET 8.0+
- .NET MAUI (iOS 15+ / Android API 21+)
- Visual Studio 2022+ or JetBrains Rider
Installation
NuGet
dotnet add package DataflySignal.MauiOr via the NuGet Package Manager in Visual Studio:
Install-Package DataflySignal.MauiInitialisation
using DataflySignal.Maui;
public partial class App : Application
{
public App()
{
InitializeComponent();
Datafly.Initialize(new DataflyConfig
{
PipelineKey = "dk_live_abc123",
Endpoint = "https://data.example.com"
});
}
}Usage
using DataflySignal.Maui;
// Track a screen view
Datafly.Screen("Home");
// Track a custom event
Datafly.Track("add_to_cart", new Dictionary<string, object>
{
{ "item_id", "SKU-001" },
{ "item_name", "Running Shoes" },
{ "price", 79.99 },
{ "currency", "GBP" }
});
// Identify a user
Datafly.Identify("user-123", new Dictionary<string, object>
{
{ "email", "jane@example.com" },
{ "name", "Jane Doe" }
});
// Associate with a company
Datafly.Group("company-456", new Dictionary<string, object>
{
{ "name", "Acme Corp" }
});
// Handle deep link
Datafly.HandleDeepLink("https://example.com?utm_source=google");
// Set consent
Datafly.SetConsent(new Dictionary<string, bool>
{
{ "analytics", true },
{ "marketing", false }
});
// Force flush
Datafly.Flush();
// Logout
Datafly.Reset();
// Read identity
string anonymousId = Datafly.AnonymousId;
string? userId = Datafly.UserId;The .NET MAUI SDK uses platform-specific implementations via conditional compilation. On iOS, it calls the native Swift SDK through ObjCRuntime bindings. On Android, it calls the native Kotlin SDK through Java.Interop bindings.
Configuration
See Configuration for all available options.