Skip to main content

Legacy Android Push Notifications

Deprecated — do not use for new games

Legacy Android SDK is in maintenance-only mode and will be removed. New games must use SDK v2 Push.

The legacy Android SDK integrates with Firebase Messaging. The SDK can surface notifications itself or let your game observe token and message callbacks.

Setup

  1. Add google-services.json to your app/ module or active source set.
  2. Configure notification defaults in app/src/main/assets/oeg_config.json.
  3. Add a status-bar notification icon named ic_stat_ic_notification.

Example config:

oeg_config.json
{
"coreConfig": {
"defaultNotificationChannelId": "default",
"defaultNotificationTitle": "Notification"
}
}

Set the icon tint color in res/values/colors.xml:

res/values/colors.xml
<color name="notificationIconColor">#04aa46</color>

Observe push token updates

OegSdk.registerNewPushDeviceTokenCallback { token ->
println("FCM token: $token")
}

Unregister when you no longer need the callback:

OegSdk.unregisterNewPushDeviceTokenCallback()

You can also request the current token on demand:

OegSdk.getPushDeviceToken { token ->
println("Current token: $token")
}

Receive push messages

OegSdk.registerOnPushNotificationMessageReceivedCallback { context, remoteMessage ->
println("Push payload: ${remoteMessage.data}")
}

If you do not register a message callback, the SDK falls back to displaying a notification with the configured title/body behavior.

Notes

  • The SDK ships its own FirebaseMessagingService implementation.
  • onNewToken is forwarded to the registered token callback.
  • onMessageReceived is forwarded to the registered message callback before the SDK decides whether to display a notification.