PushApp Unity SDK

Unity SDK for push notifications, event tracking, and in-app messages (popup, banner, PiP, roadblock, bottomsheet, tooltip, inline).

Documentation site: https://docs.mehery.com/guide/pushapp/ — hosted on MeherY docs; technical guide in this repo under docs/ (see docs/Mehery-Unity-SDK-Technical-Guide.md).


What Your App Must Add (Quick Checklist)

Your Unity game should include all of the following:

  • Firebase config files:
    • Android: google-services.json
    • iOS: GoogleService-Info.plist
  • Firebase Unity Messaging package in the game project
  • Push Notifications capability on the iOS Xcode target (and Remote notifications background mode)
  • SDK package install (pushapp.uge)
  • Device registration from game code (MeheryClient.InitializeAndSendToken)
  • User identity and tracking calls where they match your player journey:
    • MeheryClient.Login
    • MeheryClient.InitPage
    • MeheryClient.SendEvent
  • In-app poll / show only if you use in-app surfaces
  • iOS Notification Service / Content extensions only if you need rich image or carousel lock-screen UI

Part 1 — Setup

One-time project configuration before writing SDK integration code.


1.1 Dependencies

Add the package in Unity Window → Package Manager → + → Add package from git URL:

https://github.com/mehery-soccom/PushApp-Unity.git#v0.1.0

Package name: pushapp.uge
Package version: 0.1.0

For a local clone, choose Add package from disk and select this folder’s package.json.

Also add the Firebase Unity SDK with Firebase Messaging enabled. The PushApp package does not bundle Firebase.

Compatibility matrix (pushapp.uge 0.1.0)

Minimum requirements

Component Minimum Source
Unity 2021.3 package.json unity
Android (API level) 21 recommended; POST_NOTIFICATIONS on 33+ Plugin manifest
iOS deployment target 13.0+ (15.0 recommended with current Firebase) Player Settings / Xcode
Firebase Unity Messaging Host-provided Game project
google-services.json Required for Android FCM Firebase Console
GoogleService-Info.plist Required for iOS FCM/APNs bridge Firebase Console

Tested combination (example app / release QA)

Verified with the Mehery example project on device builds:

Component Tested version
Unity 6000.6.10f1
Package pushapp.uge 0.1.0
Android minSdk 26, target/compile 36, package in.co.mehery.unity
iOS physical device, Push + Remote notifications
Firebase Unity Messaging + matching Google config files

New releases document an updated matrix in CHANGELOG.md.


1.2 Firebase Console

  1. Open Firebase Console
  2. Create a project (or use an existing one)
  3. Register an Android app — use your Unity Android package name
  4. Register an iOS app — use the same bundle ID as in Xcode / Player Settings

Download and place the config files:

Platform File Location
Android google-services.json Per Firebase Unity setup (usually project Assets/)
iOS GoogleService-Info.plist Per Firebase Unity setup; must be in the Xcode app target

Upload an APNs auth key (or certificate) to the Firebase iOS app. Use the same Firebase project Mehery campaigns send through.


1.3 Add the Unity package

  1. Window → Package Manager
  2. + → Add package from git URL…
  3. Paste https://github.com/mehery-soccom/PushApp-Unity.git#v0.1.0
  4. (Optional) Select Mehery PushApp → Samples → Basic push and import

Unity imports:

  • Runtime/ — C# API (Mehery.Push)
  • Plugins/Android/ — FCM token, tray display, taps, in-app overlay
  • Plugins/iOS/ — APNs permission/token, Firebase messaging bridge, in-app overlay, rich-notification extension sources

Check plugin platforms

File Platform
Plugins/Android/*.java and AndroidManifest.xml Android only
Plugins/iOS/MeheryPushPlugin.mm iOS only

The Android manifest merges automatically. It already declares INTERNET, POST_NOTIFICATIONS, MeheryMessagingService, MeheryClickActivity, MeheryCarouselReceiver, and MeheryInAppActivity.

Do not create your own GameObject named MeheryPush. The SDK creates a hidden object with that name for native callbacks.


1.4 Android platform config

Edit → Project Settings → Player → Android:

  • Package Name matches the Firebase Android app
  • Internet Access = Require
  • Target API 33+ so POST_NOTIFICATIONS can be requested on current phones
  • Custom main manifest must not strip the merged Mehery MESSAGING_EVENT service

Resolve Android libraries with External Dependency Manager after Firebase is imported.

Build a Development Build the first time so adb logcat shows lines tagged MeheryPush.


1.5 iOS platform config

This section is the minimum for push + in-app SDK features. Notification Service Extension and Notification Content Extension are optional — see §1.7.

Edit → Project Settings → Player → iOS:

  • Bundle Identifier matches the Firebase iOS app
  • Signing team set for device builds

After Unity exports to Xcode, on the Unity-iPhone target:

  1. Signing & Capabilities → + Capability → Push Notifications
  2. + Capability → Background Modes → Remote notifications
  3. Confirm GoogleService-Info.plist is in the app target
  4. Confirm Firebase iOS frameworks link (FirebaseCore, FirebaseMessaging)

Entitlements use aps-environment. Development installs use development. App Store / TestFlight export re-signs to production.

Install on a physical iPhone. The simulator does not give a usable APNs token for this flow.

Optional: rich notification extensions

Not required for push registration, title/body alerts, or in-app messages.

Feature Package sources
Image attachment before display Plugins/iOS/NotificationService/
Custom expanded / carousel UI Plugins/iOS/NotificationContent/

After the Unity iOS export, add those two Xcode targets and point them at the package sources. Bundle ids: <game bundle id>.NotificationService and <game bundle id>.NotificationContent. Android images and carousels do not need extra targets.


1.6 Setup checklist

  • Package added (pushapp.uge from git URL or disk)
  • Firebase Unity Messaging imported
  • Android google-services.json
  • iOS GoogleService-Info.plist
  • Android package name + Firebase Android app match
  • iOS bundle id + Push capability + Remote notifications
  • Plugin platform checkboxes correct
  • (Optional) NSE / Content extension targets — see §1.7
  • Device build (Editor cannot register a push token)

Part 2 — Implementation

C# code to wire the SDK into your game. Complete Part 1 first.


2.1 Import

using Mehery.Push;
using System.Collections.Generic;
using UnityEngine;

Debug logging uses the prefix [MeheryPush] (filter logcat / Xcode / Unity console with MeheryPush).


2.2 SDK instance

Create one shared MeheryClient. Identifier is required (Mehery channel id). AppId and AppSecret are optional dashboard credentials (X-App-Id / X-App-Key):

var client = new MeheryClient(new MeheryConfig
{
    Identifier = "yourTenant_yourChannelId", // from Mehery dashboard
    AppId = "yourAppId",
    AppSecret = "yourAppSecret",
    Sandbox = false,
    DevelopmentHost = false,
});

Host selection:

Flag Server
DevelopmentHost = true https://<tenant>.pushapp.co.in
Sandbox = true https://<tenant>.pushapp.net
Both false https://<tenant>.pushapp.ai

ServerUrlOverride, when set, replaces that host. Do not include a trailing /pushapp.

Useful reads after registration / login:

  • client.IsDeviceRegistered
  • client.UserId
  • client.GuestId

2.3 Ask the phone for a token

Subscribe first, then request. Unsubscribe in OnDestroy / OnDisable.

void OnEnable()
{
    MeheryPushNative.TokenReceived += OnToken;
    MeheryPushNative.TokenFailed += OnTokenFailed;
    MeheryPushNative.NotificationOpened += OnNotificationOpen;
    MeheryPushNative.InAppClosed += OnInAppClosed;
    MeheryPushNative.InAppLink += OnInAppLink;
    MeheryPushNative.RequestToken();
}

void OnDisable()
{
    MeheryPushNative.TokenReceived -= OnToken;
    MeheryPushNative.TokenFailed -= OnTokenFailed;
    MeheryPushNative.NotificationOpened -= OnNotificationOpen;
    MeheryPushNative.InAppClosed -= OnInAppClosed;
    MeheryPushNative.InAppLink -= OnInAppLink;
}

What RequestToken does:

  • Android: on API 33+ asks notification permission, then reads the FCM token
  • iOS: asks alert/badge/sound, registers with APNs, bridges into Firebase Messaging
  • Editor: no token; registration must run on a device build

If the game already owns an FCM/APNs token, you may skip RequestToken and pass that token into InitializeAndSendToken.


2.4 Register the device

void OnToken(string token)
{
    var android = Application.platform == RuntimePlatform.Android;
    client.InitializeAndSendToken(
        android ? token : null,
        android ? null : token,
        registered =>
        {
            if (!registered)
            {
                Debug.LogWarning("[MeheryPush] device registration failed");
                return;
            }
            // Ready for Login / events
        });
}

Pass FCM as the first argument on Android. Pass APNs as the second argument on iOS.

On success the SDK:

  • POST /pushapp/api/device/register (or update/token when already registered)
  • sends install / open style session events
  • flushes any login or events that were queued early

Login and SendEvent called before registration finishes are kept and sent after it succeeds.


2.5 Login / logout

On sign-in (after your auth succeeds):

client.Login(userId, linked =>
{
    if (!linked)
    {
        return;
    }
    client.InitPage("home");
});

Account switch (same device): call Login(newUserId) with the new id. The SDK delinks the previous user when needed.

On sign-out (no replacement user):

client.Logout(userId, done => { /* done == true on HTTP 200 */ });

Logout delinks, then registers the device again as a guest so anonymous campaigns can still reach the install.


2.6 Screen tracking

client.InitPage("dashboard");

InitPage sends page_open with { "page": "dashboard" } and is the usual place to trigger an in-app poll afterward.


2.7 Custom events (optional)

client.SendEvent("game_start", new Dictionary<string, object>
{
    { "level", 1 },
    { "screen_name", "play" },
});

Event names and data keys must match the campaign or segment in Mehery. The SDK attaches identity from the logged-in user id, or the guest id when the player has not logged in.

For inline / tooltip slots, send widget_open with the placeholder id Mehery expects in compare:

client.SendEvent("widget_open", new Dictionary<string, object>
{
    { "compare", "home_inline" },
});

Send widget_open once when that placeholder appears, not every frame.


2.8 In-app messages

Campaigns are polled by the game:

client.PollInApp(messages =>
{
    if (messages == null || messages.Length == 0)
    {
        return;
    }
    var message = messages[0];
    client.AckInApp(message);
    MeheryPushNative.ShowInApp(
        message.Kind,
        message.Html,
        message.Align,
        message.CrossColor,
        message.CrossBgColor,
        message.CrossBorderColor);
});

Empty HTML shows nothing. Close / link callbacks arrive on MeheryPushNative.InAppClosed and MeheryPushNative.InAppLink. Track with client.TrackInApp(...).


2.9 Notification opens

void OnNotificationOpen(string destination)
{
    // Open the matching screen / deep link from the payload
}

Native Android/iOS code also reports open and CTA taps to the push track API. Header X-OS-Name is sent as iOS or Android.


2.10 Example implementation layout

Assets/
  Scripts/
    MeheryBootstrap.cs     ← MeheryConfig, MeheryClient, RequestToken
    GameLogin.cs           ← client.Login / Logout
    HomeScreen.cs          ← InitPage, PollInApp, SendEvent
  google-services.json
  GoogleService-Info.plist

Or import the package sample Basic push for a complete walkthrough scene.


2.11 Call order (every cold start)

  1. Build MeheryConfig and create MeheryClient
  2. Subscribe to MeheryPushNative events
  3. MeheryPushNative.RequestToken()
  4. InitializeAndSendToken when the token arrives
  5. Login with your player id
  6. InitPage / gameplay SendEvent
  7. PollInApp when a screen should show campaigns
  8. Handle NotificationOpened
  9. Logout on sign-out

Version

0.1.0 — see CHANGELOG.md for release notes.

Full setup walkthrough: docs/Mehery-Unity-SDK-Technical-Guide.md.

License

MIT


This site uses Just the Docs, a documentation theme for Jekyll.