Unity Push Notifications
Setup
- Android: FCM, from
google-services.jsonunderAssets(see Installation). Nothing else. - iOS: tick Enable iOS Push Notifications on the
AlogameSDKSettingsasset once the App ID has Push enabled in the Apple Developer portal. The build hook adds the Push capability (aps-environment), the remote-notification background mode, and the Unity flag that passes the APNs token to the SDK. It is off by default because the entitlement fails signing with a provisioning profile that has no push.
Ask for permission
Ask when it suits the game:
C#
bool granted = await AlogamePush.RequestPermission();
The SDK registers the device token with the backend, before and after login, and shows Alogame's pushes itself.
Receive messages
C#
AlogamePush.MessageReceived += data =>
{
if (data.TryGetValue("title", out var title)) Debug.Log($"push: {title}");
};
AlogamePush.TokenRefreshed += token => Debug.Log("push token rotated");
Optional
| Call | Android | iOS |
|---|---|---|
AlogamePush.GetDeviceToken() | FCM token | APNs token (hex), after permission is granted |
AlogamePush.SubscribeToTopic(topic) / UnsubscribeFromTopic(topic) | FCM topics | rejected (no APNs equivalent) |