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
- Get started with PusherHub
- Create a Firebase project
- Get your Firebase service account file
- Find your Sender ID
- iOS push notifications: add your Apple push key to Firebase
- Add push notifications to your app
- Flutter
- Android (Kotlin)
- Java
- React Native
- iOS (Swift)
- Unity
- Send a test push notification
- Send your first push notification
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/ ④.
Every step below is on this tab too, with your own keys already filled in — copy the code from there.
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.
- Download the Firebase Unity SDK from
firebase.google.com/download/unityand unzip it. - In Unity, choose
Assets
Import Package
Custom Package…
and import
FirebaseMessaging.unitypackage. - Android: choose Assets External Dependency Manager Android Resolver Force Resolve .
- iOS: install CocoaPods on the Mac that builds the game. The External Dependency Manager runs
pod installon every iOS build.
Put the files in Assets
PusherHub.cs① goes inAssets/PusherHub/.- Android:
google-services.json② goes inAssets/. - iOS:
GoogleService-Info.plist③ goes inAssets/. Firebase finds both files anywhere underAssets/when Unity builds. - The Firebase version files ④ should all show the same number — 13.3.0 here.
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.
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.
using PusherHubSDK;①[RuntimeInitializeOnLoadMethod]② makes Unity runInit()once when the game starts, in any scene.PusherHub.Initialize(…)③ with your App key, Public key and server.PusherHub.RegisterDevice(…)④ asks the player to allow notifications, gets the push token and adds the phone to PusherHub.CollectDeviceMetadataafter it is optional: it adds the phone's brand, model, language and country.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.
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();
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();
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.
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.xcworkspaceit 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.