Skip to main content
Use the Sendrealm Android SDK to receive mobile push notifications in native Kotlin or Java Android apps. If your app uses React Native, start with React Native Bare SDK or React Native Expo SDK.

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.json added to your Android app.
  • Firebase service account JSON uploaded in Sendrealm.
See Mobile Push Credentials for Firebase setup.

Install

Add the SDK dependency to your app module:
dependencies {
    implementation("com.sendrealm:sendrealm-android:0.1.2")
}
Make sure the Google Services Gradle plugin is applied to your Android app if it is not already:
plugins {
    id("com.google.gms.google-services")
}

Add google-services.json

Download google-services.json from Firebase and place it in your app module:
app/google-services.json
The Firebase Android package name must match your app applicationId.

Initialize

Initialize once during app startup:
import android.os.Bundle
import androidx.activity.ComponentActivity
import com.sendrealm.sdk.Sendrealm
import com.sendrealm.sdk.SendrealmConfig

class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        val config = SendrealmConfig()
            .setEnvironment("development")
            .setAutoRequestPermission(false)

        Sendrealm.initialize(
            context = this,
            appId = "YOUR_SENDREALM_APP_ID",
            config = config
        )
    }
}
Use 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:
Sendrealm.requestPermission(this)
Check permission state:
val allowed = Sendrealm.hasNotificationPermission(this)
Android 13 and newer show a runtime notification permission prompt. Android 12 and older do not have a runtime prompt, but users can still disable notifications in system settings.

Handle Notification Opens

Forward new launch intents to Sendrealm so notification taps can be tracked and routed:
override fun onNewIntent(intent: Intent) {
    super.onNewIntent(intent)
    setIntent(intent)
    Sendrealm.handleNotificationOpen(intent)
}
Configure your Android intent filters for any app links or deep links you want notifications to open. Call login after the user signs in:
Sendrealm.login("user-123", "user@example.com")
Call logout when the user signs out:
Sendrealm.logout()

Tags

Use tags for app-observed preferences, state, and behavior:
Sendrealm.addTags(
    mapOf(
        "plan" to "pro",
        "onboardingComplete" to true
    )
)
Do not use SDK tags for authoritative account, billing, security, compliance, or verified profile data. Update those values from your backend.

Custom Events

Track app events for segmentation, analytics, or automations:
Sendrealm.trackEvent(
    "checkout_started",
    mapOf(
        "product_id" to "sku_123",
        "price" to 29
    )
)
Use stable event names and avoid sending sensitive data unless your team intentionally wants that data stored in Sendrealm.

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 as orders, 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:
val diagnostics = Sendrealm.getDiagnostics(this)
Log.d("Sendrealm", diagnostics.toString())
Confirm diagnostics show:
  • A device ID.
  • Token presence.
  • Expected permission status.
  • Subscribed state unless the user opted out.
  • No unexpected SDK error.

Troubleshooting

SymptomWhat to check
Token is missingUse a Google Play device or emulator and verify Firebase setup.
Notifications do not displayCheck notification permission, Android channel settings, and notification icon resources.
Notifications are delayedCheck Android power settings, FCM priority, device connectivity, and user notification settings.
Sound does not changeAndroid may be keeping the original channel behavior. Use a new channel ID.
Deep link does not openVerify the notification URL and Android intent filters.
Tags fail with ContactNotLinkedCall login(userId, email) before setting user tags.