Android Push Notifications in Kotlin (FCM)

Kotlin/Java, minSdk 23. Firebase Cloud Messaging with a ready-made full-screen call UI.

🤖 Android

Kotlin/Java, minSdk 23. Firebase Cloud Messaging with a ready-made full-screen call UI.

Download the SDK from the dashboard (Integration guide) after you create a free account.

  1. Set up Firebase

    • Create an Android app in the Firebase Console and put google-services.json in the app/ folder.
    • In TingPush: upload the service account JSON of that same Firebase project.
  2. Add the SDK module

    Unzip the download into your project's root folder (this creates PushConsoleSDK/) and declare the module:

    Gradle (Kotlin DSL)
    // settings.gradle.kts
    include(":pushconsole")
    project(":pushconsole").projectDir = file("PushConsoleSDK/android/pushconsole")
    
    // app/build.gradle.kts
    plugins {
        id("com.google.gms.google-services")   // Firebase
    }
    dependencies {
        implementation(project(":pushconsole"))
    }

    Requires minSdk 23 and Kotlin 2.x. With AGP 9's built-in Kotlin, remove the id("org.jetbrains.kotlin.android") line in pushconsole/build.gradle.kts. Permissions, the FCM service and the call screen are declared in the SDK — no manifest changes needed.

  3. Initialize in Application

    Initialize and set the listener in Application.onCreate so no event is missed when the app is woken up from a closed state.

    App.kt
    class App : Application() {
        override fun onCreate() {
            super.onCreate()
            PushConsole.init(
                this,
                appId = "YOUR_APP_ID",
                serverUrl = "https://tingpush.com",
                options = PushConsole.Options(
                    notificationIcon = R.drawable.ic_notification,
                    callTexts = CallTexts(answer = "Answer", decline = "Decline"),
                ),
            )
            PushConsole.listener = object : PushConsoleListener {
                override fun onCallAccepted(call: CallInfo) {
                    // User tapped Answer → connect the call (call.id, call.data["room"])
                }
                override fun onCallDeclined(call: CallInfo) { }
                override fun onCallMissed(call: CallInfo) { }
                override fun onCallEnded(callId: String) { }
                override fun onNotificationOpened(data: Map<String, String>) {
                    // navigate using data["screen"]...
                }
            }
        }
    }
    
    // AndroidManifest.xml: <application android:name=".App" ...>
  4. Main activity

    MainActivity.kt
    class MainActivity : AppCompatActivity() {
        override fun onCreate(savedInstanceState: Bundle?) {
            super.onCreate(savedInstanceState)
            PushConsole.requestNotificationPermission(this)  // Android 13+
            PushConsole.handleIntent(intent)                 // opened from a notification / Answer tapped
        }
    
        override fun onNewIntent(intent: Intent) {
            super.onNewIntent(intent)
            PushConsole.handleIntent(intent)
        }
    }
  5. Assign the user at login

    Kotlin
    PushConsole.login("user-123")                 // after login
    PushConsole.logout()                          // on logout
    PushConsole.setTags(mapOf("plan" to "vip"))
    PushConsole.endCall(callId)                   // dismiss the ringing screen

    Java: PushConsole.init(...), PushConsole.login(...), PushConsole.INSTANCE.setListener(...).

  6. Reliable call ringing

    Kotlin
    // "Call settings" screen in your app
    if (!PushConsole.canUseFullScreenIntent(this)) {
        PushConsole.openFullScreenIntentSettings(this)      // Android 14+
    }
    if (!PushConsole.isIgnoringBatteryOptimizations(this)) {
        PushConsole.openBatteryOptimizationSettings(this)   // Xiaomi, Oppo, Vivo…
    }

    Xiaomi, Oppo, Vivo, Realme: guide users to enable Autostart and turn off battery optimization (as WhatsApp does).

✅ After integrating, check

  1. Run the app on a real device with logging on: you should see [PushConsole] Device registered ….
  2. The project's Devices tab: the device appears; iOS devices show the VoIP badge if you use calls.
  3. The Send tab: send a test to that device.
  4. Choose 📞 Call and test with the app open, closed and with the screen locked.

Ready to integrate?

Create an account to get your App ID and API Key and download the SDKs. Dashboard samples are pre-filled with your project details.