Skip to content

.NET MAUI Mobile Application Implementation Guide

Abstract

In this section we will walk through how you can implement and verify WOGAA tracking for your mobile application on iOS and Android.

Warning

Do not reshare this document with anyone unless they need to implement WOGAA tracking on their mobile applications.


Dependencies

  1. Visual Studio
  2. LiteDB 5.0.16
  3. Snowplow Tracker 1.2.1
  4. Snowplow Tracker PlatformExtensions 1.2.1
  5. Android SDK API 16 and above
  6. Target Framwork 9.0

Info

DotNet MAUI Tracker uses Snowplow DotNet Trackers.


Step 1. Install dependencies

Install LiteDB

  1. Open Manage NuGet Packages
  2. Search for LiteDB
  3. Select LiteDB with version 5.0.16
  4. Click Add Package

Install Snowplow Tracker

  1. Open Manage NuGet Packages
  2. Search for Snowplow Tracker
  3. Select Snowplow Tracker
  4. Click Add Package

Install Snowplow Tracker PlatformExtensions

  1. Open Manage NuGet Packages
  2. Search for Snowplow Tracker PlatformExtensions
  3. Select Snowplow.Tracker.PlatformExtensions
  4. Click Add Package

Step 2. Implement codes for .NET MAUI tracking

Wogaa Tracker

  1. Copy WogaaTracker.cs to the main project directory.
  2. Update the namespace in WogaaTracker.cs - MultieplatformApp to your project namespace.
  3. Add the following code into the App.cs
protected override void OnStart()
{
    if (Tracker.Instance.Started)
    {
        Tracker.Instance.SetBackground(false);
    }
}

protected override void OnSleep()
{
    if (Tracker.Instance.Started)
    {
        Tracker.Instance.SetBackground(true);
    }
}

protected override void OnResume()
{
    if (Tracker.Instance.Started)
    {
        Tracker.Instance.SetBackground(false);
    }
}

.NET MAUI

.NET MAUI

Add the following code into App.xaml.cs App function after InitializeComponent()

if (!Snowplow.Tracker.Tracker.Instance.Started)
{
    WogaaTracker.Init(
        url: WogaaTracker.ENVIRONMENT.staging,
        appId: "com.xxxx.xxx"
    );
}

Add following code to all ContentPage into Constructor function, and replace the Screen Name to your actual screen name.

 WogaaTracker.TrackScreenView("Screen Name");

iOS

Add the following code into AppDelegate.cs WillTerminate function

WogaaTracker.Shutdown();

Android

Add the following code into MainApplication.cs OnTerminate function

WogaaTracker.Shutdown();

Step 4. Check MAUI implementation

Method 1: Manually check the logs

Run your application using Xcode or Android Studio and verify the platform logs below

iOS

Info: Emitter flushed all (1) events successfully

Note

Info: Emitter flushed all (1) events successfully shows number of successful event(s) being sent to our backend system

Android

Info: Emitter sent and deleted 1 events

Note

Info: Emitter sent and deleted 1 events shows number of successful event(s) being sent to our backend system

Method 2: Use tool to check if data is being received in your environment(s).

Info

  • Staging received events will take about 10 seconds to process. (Last 24 hours)
  • Production received events will take about 1 day to process.

Step 4. Verification of MAUI Implementation

Move to Production

Change the Environment variable from Staging to Production.

WogaaTracker.ENVIRONMENT.Production

A verification email will be sent once we have successfully received data from your mobile application in production server.

It may take up to 7 working days for the verification. Please let us know if there is any issues with regards to this via support@wogaa.gov.sg