Supported on: Android SDK
1.0.33+Prerequisites
Before using push notifications, configure FCM for your app:- Add
google-services-appdna.json(or your project’sgoogle-services.json) to yourapp/src/main/assets/directory. - Apply the
com.google.gms.google-servicesGradle plugin in your app module. - Enable Firebase Cloud Messaging in the Firebase Console.
- Upload your FCM service account credentials (or legacy server key) to the AppDNA Console under Settings > Push > Android Configuration.
Request Permission
On Android 13+ (API 33), push notifications require thePOST_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:
onRequestPermissionsResult or call setPushPermission afterwards. On API < 33 the call is a no-op and returns true.
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 yourFirebaseMessagingService:
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: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
| Method / Property | Signature | Description |
|---|---|---|
token | token: String? | The currently registered FCM device token |
getToken | getToken(): String? | Returns the current device token |
setToken | setToken(token: String) | Registers the push token with AppDNA backend |
requestPermission | suspend fun requestPermission(activity: Activity? = null): Boolean | Request POST_NOTIFICATIONS (Android 13+) via Activity Result API. Returns true once granted (or on API < 33). Requires a ComponentActivity to host the launcher. |
requestPermissionFuture | requestPermissionFuture(activity: Activity?): CompletableFuture<Boolean> | Java-friendly variant of requestPermission |
trackDelivered | trackDelivered(pushId: String) | Track push delivery |
trackTapped | trackTapped(pushId: String, action: String?) | Track push tap with optional action |
setDelegate | setDelegate(delegate: AppDNAPushDelegate?) | Set a delegate for push lifecycle callbacks |
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.
AppDNAPushDelegate interface to receive push notification lifecycle callbacks:
Example Implementation
PushPayload
ThePushPayload data class contains the notification content:
| Property | Type | Description |
|---|---|---|
pushId | String | Unique identifier for the notification |
title | String | Notification title |
body | String | Notification body text |
imageUrl | String? | URL to a rich notification image |
data | Map<String, Any>? | Custom data payload |
action | PushAction? | Action to perform when tapped |
PushAction
ThePushAction data class defines the action associated with a notification tap:
| Property | Type | Description |
|---|---|---|
type | String | Action type (e.g., "deep_link", "url", "screen") |
value | String | Action value (e.g., a URL or screen identifier) |
Auto-Tracked Events
The SDK automatically tracks the following push-related events:| Event | Triggered When |
|---|---|
push_token_registered | Device token is successfully registered |
push_permission_granted | User grants push permission |
push_permission_denied | User denies push permission |
push_delivered | A push notification is delivered |
push_tapped | User taps on a push notification |
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
- Set up Billing to handle in-app purchases
- Configure Onboarding flows
- Present Paywalls with purchase handling
- Learn about Offline Support for event resilience

