AppAmbit: Getting Started with MAUI
This guide walks you through setting up the AppAmbit .NET SDK in your application, focusing on AppAmbit Analytics and Crash Reporting.
1. Prerequisites
Before getting started, ensure you meet the following requirements:
- The target devices run iOS 11.0 or higher, or Android 5.0 (API level 21) or higher.
Supported Platforms
- MAUI for iOS
- MAUI for Android
- MAUI for Windows (coming soon)
- MAUI for macOS (coming soon)
2. Creating Your App in the AppAmbit Portal
- Visit AppAmbit.com.
- Sign in or create an account. Navigate to "Apps" and click on "New App".
- Provide a name for your app.
- Select the appropriate release type and target OS.
- Click "Create" to generate your app.
- Retrieve the App Key from the app details page.
- Use this App Key as a parameter when calling
.UseAppAmbit("<YOUR-APPKEY>")in your project.
Adding the AppAmbit SDK to Your Solution
NuGet
Add the package to your MAUI project:
dotnet add package com.AppAmbit.Sdk
# or specify version
dotnet add package com.AppAmbit.Sdk --version 1.0.1
Or, using Visual Studio:
- Right-click your project → Manage NuGet Packages…
- Search for AppAmbit and install the latest stable version.
Initializing the SDK
To begin using AppAmbit, you need to explicitly enable the services you wish to use. No services are activated by default.
Import the Namespace
Add the required using directive to your file:
using AppAmbit;
Using .UseAppAmbit()
Call .UseAppAmbit("<YOUR-APPKEY>") during application initialization:
.UseAppAmbit("<YOUR-APPKEY>");
Here's an example of how to configure it within your MauiProgram class:
using AppAmbit;
public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.UseAppAmbit("<YOUR-APPKEY>");
return builder.Build();
}
}
This code automatically generates a session, the session management is automatic.
Android Requirements
Add the following permissions in your AndroidManifest.xml:
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
iOS and macOS (coming soon) Requirements
For iOS, add the required URL exceptions in your Info.plist file:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>appambit.com</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key>
<true/>
</dict>
</dict>
</dict>