PusherHub

Docs Add PusherHub to your app

Unity push notifications: add the SDK step by step

Android and iOS, every step with a picture from a real Unity game: the Firebase Messaging package, where the files go, and the one script that starts PusherHub.

8 min read

All guides
1

Download PusherHub.cs

In the dashboard, open Applications your game SDK Integration and pick Unity ①. Choose where your game runs — Android + iOS ② here — and click Download PusherHub.cs ③. It goes in Assets/PusherHub/ ④.

1 Pick Unity · 2 Android + iOS · 3 Download the SDK file · 4 The folder it goes in

Every step below is on this tab too, with your own keys already filled in — copy the code from there.

2

Add Firebase Cloud Messaging for Unity

PusherHub sends through Firebase Cloud Messaging, so the game needs Firebase's Messaging package. It's the only thing PusherHub.cs needs — in-app messages are drawn with Unity UI.

  1. Download the Firebase Unity SDK from firebase.google.com/download/unity and unzip it.
  2. In Unity, choose Assets Import Package Custom Package… and import FirebaseMessaging.unitypackage.
  3. Android: choose Assets External Dependency Manager Android Resolver Force Resolve .
  4. iOS: install CocoaPods on the Mac that builds the game. The External Dependency Manager runs pod install on every iOS build.
3

Put the files in Assets

  1. PusherHub.cs ① goes in Assets/PusherHub/.
  2. Android: google-services.json ② goes in Assets/.
  3. iOS: GoogleService-Info.plist ③ goes in Assets/. Firebase finds both files anywhere under Assets/ when Unity builds.
  4. The Firebase version files ④ should all show the same number — 13.3.0 here.
1 PusherHub.cs · 2 google-services.json · 3 GoogleService-Info.plist · 4 The same Firebase version
4

iOS: Player Settings

Open Edit Project Settings Player iOS Other Settings and set:

  • Bundle Identifier — the same one as in Firebase.
  • Signing Team ID — your paid Apple Developer team, with Automatically Sign on.
  • Target minimum iOS Version — 15.0 or later (Firebase needs it).

There's nothing to set up in Xcode. On every iOS build, PusherHub.cs adds the Push Notifications capability, background notifications, and a Notification Service Extension that shows notification pictures. If the game already has one (OneSignal adds its own), it adds the picture download to that one instead.

5

Start PusherHub when the game starts

Make a new script, Assets/Scripts/PusherHubSetup.cs, with the code from your SDK Integration tab — your keys and server are already filled in. (In the picture they're placeholders.) It doesn't go on a GameObject.

  1. using PusherHubSDK; ①
  2. [RuntimeInitializeOnLoadMethod] ② makes Unity run Init() once when the game starts, in any scene.
  3. PusherHub.Initialize(…) ③ with your App key, Public key and server.
  4. PusherHub.RegisterDevice(…) ④ asks the player to allow notifications, gets the push token and adds the phone to PusherHub. CollectDeviceMetadata after it is optional: it adds the phone's brand, model, language and country.
  5. PusherHub.EnableInAppMessages() ⑤ — optional: shows your in-app messages now and every time the game comes back to the front. Leave it out if you only send notifications.
1 using PusherHubSDK · 2 Runs when the game starts · 3 Your keys · 4 Register the phone · 5 In-app messages (optional)

Rather show in-app messages only at calm moments, such as when your main menu opens? Leave out ⑤ and call this there instead:

PusherHub.CheckForInAppMessages();
6

Optional: log the player in

If your game has its own sign-in, tell PusherHub who's playing. Then you can send to one person by your own user ID. It's remembered, even after the game restarts, until Logout().

// When someone signs in:
PusherHub.Login(currentUserId);

// When they sign out:
PusherHub.Logout();
7

Optional: open a screen when a notification is tapped

Put your own data in Custom Data when you create a notification — say {"campaign_id": "232"} — and your game gets it back whenever someone taps that notification, whether it was open, in the background or closed. Add onNotificationOpened to the PusherHub.Initialize(…) from step 5:

PusherHub.Initialize(
    appKey: "YOUR_APP_KEY",
    publicKey: "YOUR_PUBLIC_KEY",
    baseUrl: "YOUR_SERVER",
    onNotificationOpened: data =>
    {
        if (data.TryGetValue("campaign_id", out var campaignId))
        {
            CampaignScreen.Open(campaignId); // your own code
        }
    });

Every value arrives as text ("232"). This needs PusherHub.cs from 24 October 2026 or later — download it again if yours is older.

8

Build and run on a phone

  • Android: connect the phone, open File Build Profiles (Build Settings before Unity 6), pick Android and click Build And Run.
  • iPhone: pick iOS and click Build. Open the Unity-iPhone.xcworkspace it makes in Xcode, choose a real iPhone — the simulator can't get push notifications — and click Run ▶.

Tap Allow when the game asks about notifications. Within a few seconds the phone shows up in PusherHub under Devices. Then send it a test notification.