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.

The SDK is free and open source (MIT) on GitHub. Create a free account to get your App ID.

  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

    The SDK is published on JitPack: add the JitPack repository and the dependency:

    Gradle (Kotlin DSL)
    // settings.gradle.kts
    dependencyResolutionManagement {
        repositories {
            google()
            mavenCentral()
            maven("https://jitpack.io")
        }
    }
    
    // app/build.gradle.kts
    plugins {
        id("com.google.gms.google-services")   // Firebase
    }
    dependencies {
        implementation("com.github.DaoChiMinh:tingpush-sdk:1.1.1")
    }

    Requires minSdk 23. 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()
            TingPush.init(
                this,
                appId = "YOUR_APP_ID",
                options = TingPush.Options(
                    notificationIcon = R.drawable.ic_notification,
                    callTexts = CallTexts(answer = "Answer", decline = "Decline"),
                ),
            )
            TingPush.listener = object : TingPushListener {
                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) { }
                // User tapped a notification (even when the app was closed)
                override fun onNotificationOpened(notification: TingPushNotification) {
                    // navigate using notification.data["screen"]...
                }
                // Notification received while the app is open
                override fun onNotificationReceived(notification: TingPushNotification) { }
            }
        }
    }
    
    // AndroidManifest.xml: <application android:name=".App" ...>
  4. Main activity

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

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

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

  6. Reliable call ringing

    Kotlin
    // "Call settings" screen in your app
    if (!TingPush.canUseFullScreenIntent(this)) {
        TingPush.openFullScreenIntentSettings(this)      // Android 14+
    }
    if (!TingPush.isIgnoringBatteryOptimizations(this)) {
        TingPush.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 [TingPush] 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. Dashboard samples are pre-filled with your project details.