.NET MAUI and Unity

Pushtifly SDKs for .NET MAUI (NuGet) and Unity (UPM package), on top of Firebase Cloud Messaging.

Both SDKs share the same C# core: device registration with an offline queue, external user, tags, topics, test devices and reporting of receipts, opens and clicks. The token and messages arrive through Firebase Cloud Messaging (FCM on Android and iOS).

.NET MAUI

Installation

dotnet add package Pushtifly.Maui
dotnet add package Plugin.Firebase.CloudMessaging

Set up Firebase following the Plugin.Firebase guide (google-services.json on Android, GoogleService-Info.plist on iOS). On iOS, Firebase delivers through APNs: upload the .p8 key to Firebase and see iOS via FCM.

Usage

using Plugin.Firebase.CloudMessaging;
using Pushtifly;
using PushtiflySdk = Pushtifly.Maui.Pushtifly;

// In App.OnStart (once)
var fcm = CrossFirebaseCloudMessaging.Current;
fcm.TokenChanged += (_, e) => PushtiflySdk.HandleToken(e.Token);
fcm.NotificationReceived += (_, e) => PushtiflySdk.HandleReceived(e.Notification.Data, e.Notification.Title, e.Notification.Body);
fcm.NotificationTapped += (_, e) => PushtiflySdk.HandleOpened(e.Notification.Data, e.Notification.Title, e.Notification.Body);

await PushtiflySdk.InitAsync(new PushtiflyOptions
{
    AppKey = "pk_live_YOUR_PUBLIC_KEY",
    AndroidChannel = new AndroidChannel { Id = "general", Name = "Alerts" },
}, tokenProvider: async () => { await fcm.CheckIfValidAsync(); return await fcm.GetTokenAsync(); });

PushtiflySdk.OnNotificationOpened(n => Shell.Current.GoToAsync(n.DeepLink ?? "//home"));

// When it makes sense to ask (not the first time the app opens)
await PushtiflySdk.RequestPermissionAsync();

// On sign-in and sign-out
PushtiflySdk.Identify("user-123");
PushtiflySdk.Logout();

In App.OnResume, call PushtiflySdk.Wake() to retry whatever was left pending while offline.

Method What it does
InitAsync(options, tokenProvider) Starts the SDK; with permission granted, it registers the device.
RequestPermissionAsync() Asks for permission (Android 13+ and iOS) and registers.
Identify(id) / Logout() Links or unlinks your user.
SetTags(tags, replace) Tags for segmentation (null deletes a key).
Subscribe(topic) / Unsubscribe(topic) Topics.
PairTestDeviceAsync(code) Pairs the phone as a test device (code from the dashboard).
OnNotificationOpened / OnNotificationReceived Callbacks with Id, DeepLink, ActionId, Data and Media.

On Android, the system shows the image. On iOS, images, buttons and the carousel need Pushtifly's extensions: the templates are in the iOS SDK (PushtiflyNotificationService and PushtiflyNotificationContent). Turn them on with IosNotificationServiceExtension and IosNotificationContentExtension.

Unity

Installation

  1. Add the Firebase Unity SDK (Cloud Messaging) to your project along with its configuration (google-services.json / GoogleService-Info.plist).
  2. In Window > Package Manager > + > Add package from git URL, add the com.daertech.pushtifly package (the repository's sdks/unity folder), or copy that folder into Packages/.

Usage

using Firebase;
using Pushtifly;
using UnityEngine;
using PushtiflySdk = Pushtifly.Unity.Pushtifly;

public class Notifications : MonoBehaviour
{
    private async void Start()
    {
        await FirebaseApp.CheckAndFixDependenciesAsync();
        await PushtiflySdk.InitAsync(new PushtiflyOptions { AppKey = "pk_live_YOUR_PUBLIC_KEY" });
        PushtiflySdk.OnNotificationOpened(n => Debug.Log("Opened: " + n.DeepLink));
        await PushtiflySdk.RequestPermissionAsync();
    }
}

The API is the same as in MAUI (Identify, SetTags, Subscribe, PairTestDeviceAsync…). The SDK listens to Firebase's TokenReceived and MessageReceived for you, stores its state in PlayerPrefs and retries pending work when the game comes back to the foreground.

While the game is open, Firebase doesn't show the notification: it arrives at OnNotificationReceived and your game decides how to show it. On iOS, for images and buttons, export the Xcode project and add the iOS SDK's extensions.

Without the SDK (REST)

With any other push library, register the token via REST as in the general guide, with framework: "maui" or framework: "unity".