Skip to main content
Supported on: Android SDK 1.0.33+
The AppDNA SDK provides a complete push notification module for registering device tokens via Firebase Cloud Messaging (FCM), handling notification delivery, and tracking user interactions.

Prerequisites

Before using push notifications, configure FCM for your app:
  1. Add google-services-appdna.json (or your project’s google-services.json) to your app/src/main/assets/ directory.
  2. Apply the com.google.gms.google-services Gradle plugin in your app module.
  3. Enable Firebase Cloud Messaging in the Firebase Console.
  4. Upload your FCM service account credentials (or legacy server key) to the AppDNA Console under Settings > Push > Android Configuration.
Push notifications will not be delivered to your users without google-services-appdna.json in your project AND FCM credentials uploaded to the AppDNA Console.

Request Permission

On Android 13+ (API 33), push notifications require the POST_NOTIFICATIONS runtime permission. Request it from a coroutine — requestPermission is a suspend function that uses the Activity Result API internally and returns a Boolean once the user responds:
The SDK handles the runtime prompt and updates internal permission state automatically — you do not need to override onRequestPermissionsResult or call setPushPermission afterwards. On API < 33 the call is a no-op and returns true.
The activity parameter must be a ComponentActivity (or subclass like AppCompatActivity / FragmentActivity). The Activity Result API the SDK uses requires ComponentActivity.
Java-friendly variant: AppDNA.push.requestPermissionFuture(activity): CompletableFuture<Boolean>.

Set Token Manually

Register the device push token when it is received from FCM. This is typically done in your FirebaseMessagingService:
You can also use the alternative method name:
Both setPushToken and onNewPushToken perform the same operation. The token registration payload sent to the backend includes: token, platform="android", device_id, app_version, sdk_version, and os_version.

Set Permission Status

Manually update the SDK with the current push permission status:
On Android 13+ (API 33), push notifications require the POST_NOTIFICATIONS runtime permission. Call setPushPermission after the user responds to the permission request.

Track Delivery and Taps

Track when a push notification is delivered to the device:
Track when a user taps on a push notification:
The action parameter is optional. Pass null if no specific action is associated with the tap.

Push Module

Access the push module directly for advanced usage:

PushModule Methods

AppDNAPushDelegate

All 3 methods on this delegate fire from the SDK’s push pipeline:
  • onPushTokenRegistered(token) — fires whenever the SDK registers a new FCM token (or detects a change). Token registration with the AppDNA backend continues regardless of whether you implement this method.
  • onPushReceived(notification, inForeground) — fires when a push arrives.
  • onPushTapped(notification, actionId) — fires when the user taps a notification or one of its action buttons.
Implement the AppDNAPushDelegate interface to receive push notification lifecycle callbacks:

Example Implementation

PushPayload

The PushPayload data class contains the notification content:

PushAction

The PushAction data class defines the action associated with a notification tap:

Auto-Tracked Events

The SDK automatically tracks the following push-related events:
Auto-tracked events are sent alongside any manually tracked events. You do not need to track these events yourself.

Full Example

The SDK automatically handles token refresh. When FCM issues a new token via FirebaseMessagingService.onNewToken, call AppDNA.setPushToken(token) (or AppDNA.onNewPushToken(token)) to update registration with the AppDNA backend.

Next Steps