Requirements
- Android API 27 or newer.
- Google Play services on the target device or emulator.
- A Sendrealm app ID from the dashboard.
- Firebase Cloud Messaging configured for the same Android package name.
google-services.jsonadded to your Android app.- Firebase service account JSON uploaded in Sendrealm.
Install
Add the SDK dependency to your app module:Add google-services.json
Download google-services.json from Firebase and place it in your app module:
applicationId.
Initialize
Initialize once during app startup:development for test builds you want to target separately. Omit setEnvironment for production.
Most apps should keep setAutoRequestPermission(false) and ask for notification permission after an in-app explanation.
Ask For Permission
Ask for permission from a user action:Handle Notification Opens
Forward new launch intents to Sendrealm so notification taps can be tracked and routed:Link A Signed-In User
Calllogin after the user signs in:
logout when the user signs out:
Tags
Use tags for app-observed preferences, state, and behavior:Custom Events
Track app events for segmentation, analytics, or automations:Notification Channels
Android 8 and newer use notification channels for sound, vibration, importance, and visibility. Create separate channel IDs for materially different notification behavior, such asorders, promotions, or account_alerts.
Android may keep the original behavior for a channel after it is created. If you need to change sound or importance in a way users should notice, use a new channel ID.
Diagnostics
Use diagnostics while testing:- A device ID.
- Token presence.
- Expected permission status.
- Subscribed state unless the user opted out.
- No unexpected SDK error.
Troubleshooting
| Symptom | What to check |
|---|---|
| Token is missing | Use a Google Play device or emulator and verify Firebase setup. |
| Notifications do not display | Check notification permission, Android channel settings, and notification icon resources. |
| Notifications are delayed | Check Android power settings, FCM priority, device connectivity, and user notification settings. |
| Sound does not change | Android may be keeping the original channel behavior. Use a new channel ID. |
| Deep link does not open | Verify the notification URL and Android intent filters. |
Tags fail with ContactNotLinked | Call login(userId, email) before setting user tags. |