To get started, you need to:
- Sign up for UGS, including Analytics.
- Link your dashboard project to a Unity Editor project.
- Initialize UGS in your game code.
To use Push Notifications, you need to sign up for Unity Analytics, which is part of Unity Gaming Services (UGS). For more information about Analytics pricing, see here. To learn more about Push Notifications fair usage visit here.
- Sign into the Unity Services Dashboard.
- Select Explore Services in the side panel.
- Select Sign Up in the top banner and follow the instructions.
- Review Analytics documentation
Link your project
To use the Unity Push Notifications service, you’re required to link your project to a cloud project in the Unity Editor through a project ID. Follow these steps to get your project ID.
- In the Unity Editor menu, go to Edit -> Project Settings to open the Services tab.
- If you’re not already signed in with your Unity ID, either create a new Unity ID or sign in.
- If you want to create a new project, select your organization and select Create. If you want to link to an existing project, select I already have a Unity Project ID.
- Select your organization and project from the dropdown, and select Link.
You can find your project ID from the Settings tab in the Services window.
Summary of the integration steps:
- Integrate the SDK: Integrate package, register for Push Notifications, and enter settings/keys.
- Upload keys: Locate and upload private keys (Firebase & Apple) to the Unity Dashboard.
- Test integration: Send a test notification to your device to ensure integration is correct.
- Create notification campaign: Create and schedule your first notification on the Unity Dashboard.
1. Integrate the Push Notifications SDK
Install the Push Notifications SDK
You can install the Push Notifications SDK inside your Unity Project in one of three ways:
1. Import using the Unity Registry
- Open your Project Settings from Edit -> Project Settings.
- Enable pre-release packages from Package Manager -> Advanced Settings -> Enable Pre-release Packages.
- Open the package manager from Component -> Package Manager.
- Under the Packages dropdown, select
- Search for
Push Notificationsin the search bar in the top right to view the Push Notifications package.
Installin the top right.
2. Import by name
- Open the package manager through Component -> Package Manager.
- Select the Add (+) button in the top left to add a new package and select Add package by name.
- Type in com.unity.services.push-notifications as the Git URL and add.
3. Import using the "manifest.json" file
Copy the following code snippet and adjust the package version:
Go to the root of your project folder in the file explorer, then go to the package folder
Add the copied code at the end of the
manifest.jsonfile and append a
,at the end if needed.
Register for Push Notifications
To receive Push Notifications, your app needs to register for Push Notifications. Follow Registering for Push Notifications for details.
2. Upload your service keys
To send notifications from the Unity Gaming Services dashboard, you need to upload service keys from Firebase for Android and from your Apple Developer account for iOS.
You need a Firebase Service Account Key to be added to your Unity project settings before sending notifications to Android devices. This needs to be done for every UGS environment of the game that you expect to test or use notifications with.
- Go to your Firebase Console and select your project.
- Go to Project Settings and select Service accounts at the top.
- Select Create service account.
- Select Generate new private key.
- Select Generate key to download the key file.
- Go to Liveops > Push Notifications > Settings for your project in the Unity Dashboard then go to Google Keys and select the
Add Keyor Edit Icon in the "Google Key" row.
- Upload the private key created in the previous steps and select Finish.
You need to add an Apple key, project, and account details to your Unity project settings before sending notifications to Apple devices. You can reuse the same Apple key between games, environments, and development and production builds in the Unity Dashboard (go to step 8 if you already have one). This needs to be done for every UGS environment of the game that you expect to test or use notifications with.
Log in to your Apple Developer console.
Go to the Certificates, Identifiers & Profiles page and select Keys.
Select + to create a new key.
Name your key and enable the “Apple Push Notifications service (APNs)” option to enable notifications, then select Continue. Note, you can only enable this capability on two keys per account.
Select Register on the next page to confirm.
Download the generated key and make note of the Key ID provided as you’ll need it later. You can only download the key file once; it needs to be revoked and regenerated if lost.
Go to Player Engagement > Notifications > Settings for your project in the Unity Dashboard, click the
Set Up Keyslink in the Setup banner at the top, then select
Add Keyor the Edit Icon in the "Apple Key" row.
There are five fields that need to be populated:
- Key: Upload the key created in the previous steps.
- Key ID: This is provided when you registered the key and can also be retrieved by selecting the key in the Apple Developer console.
- Team ID: This is your team ID displayed under your account name on the Apple Developer console.
- Topic ID: Populate with the bundle identifier for your game. It needs to exactly match the one in “Identifiers” in the “Certificates, Identifiers & Profiles” page in your Apple Developer console.
- Sandbox: If you want to message players from a development/debug build of your game, set the sandbox value to True. If you want to message users on a production build, set to False.
Select Finish. For security reasons this file won’t be visible if you re-enter the edit settings page.
When building the application within XCODE, ensure that the app is given the “Remote Notification” capabilities so it can receive notifications.
You’ll receive the following error message at runtime if you fail to do this:
Failed to register for remote notifications: no valid “aps-environment” entitlement string found for application
3. Test your integration
Test your Push Notification integration within your app by following the testing guide.
If you encounter any issues whilst testing, follow the troubleshooting guide for debugging common issues.
4. Create a notification campaign
You can now create your first notification campaign to start using Push Notifications.