<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Vitalii Voitenko on Medium]]></title>
        <description><![CDATA[Stories by Vitalii Voitenko on Medium]]></description>
        <link>https://medium.com/@Vetal_3534?source=rss-ebca308e14eb------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*SHisfnHlnxUnvOng3So7Mw.png</url>
            <title>Stories by Vitalii Voitenko on Medium</title>
            <link>https://medium.com/@Vetal_3534?source=rss-ebca308e14eb------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 13:23:41 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@Vetal_3534/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Local Notifications in Compose Multiplatform: A Complete Guide for Android and iOS ]]></title>
            <link>https://medium.com/@Vetal_3534/local-notifications-in-compose-multiplatform-a-complete-guide-for-android-and-ios-92a2d87374fb?source=rss-ebca308e14eb------2</link>
            <guid isPermaLink="false">https://medium.com/p/92a2d87374fb</guid>
            <category><![CDATA[android-notification]]></category>
            <category><![CDATA[kotlin-multiplatform]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[push-notification]]></category>
            <category><![CDATA[compose-multiplatform]]></category>
            <dc:creator><![CDATA[Vitalii Voitenko]]></dc:creator>
            <pubDate>Sat, 06 Jun 2026 12:49:59 GMT</pubDate>
            <atom:updated>2026-06-06T12:49:59.545Z</atom:updated>
            <content:encoded><![CDATA[<p><em>If you’ve ever tried to get notifications working on both Android and iOS from a single codebase, you know the feeling. Android demands notification channels, pending intents, and permission checks. iOS hits you with </em><em>UNUserNotificationCenter, delegates, and Apple-specific frameworks. It often feels like trying to make a cat and a dog agree on a mobile architecture, two completely different systems, yet your KMP codebase has to speak both languages fluently.</em></p><p>Welcome to the next part of our production-ready KMP series! After setting up remote behavior with <a href="https://medium.com/@Vetal_3534/how-to-connect-firebase-remote-config-to-a-compose-multiplatform-app-a-step-by-step-guide-d75f79d257d4"><strong>Firebase Remote Config</strong></a> and measuring user steps with <a href="https://medium.com/@Vetal_3534/what-your-users-really-want-tracking-behavior-in-kmp-projects-using-amplitude-8c983b8e69c5"><strong>Amplitude Analytics</strong></a>, it’s time to talk to our users directly.</p><p>In this article, we’ll build a clean, reusable local notification system from scratch, handle native runtime permissions, fire local notifications, and implement reliable deep link navigation all through a single shared interface.</p><h3>What’s inside:</h3><ul><li>Shared interface design with expect/actual</li><li>Android implementation: channels, PendingIntent, and activity permission bridges</li><li>iOS implementation: UNUserNotificationCenter and Swift app delegate wiring</li><li>Deep link navigation when tapping a notification (handling both foreground and cold start cases)</li><li>Wiring everything together with <strong>Koin</strong></li><li>Potential pitfalls to fix before production ⚠️</li></ul><h3>The Architecture Overview 🗺️</h3><p>Before writing any code, let’s agree on the design. The idea follows the exact same pattern we used for Amplitude and Firebase: one interface in commonMain, and two concrete implementations in androidMain and iosMain.</p><p>The tricky part here isn’t showing a notification — that’s relatively straightforward. The real challenge is <strong>what happens when the user taps it</strong>.</p><p>On Android, a notification tap delivers an Intent to your Activity. On iOS, that same tap triggers a delegate method in AppDelegate. Both of these are completely platform-specific entry points, but we need to funnel them into our shared Compose navigation graph.</p><p>To solve this, we’ll build NotificationNavigator — a shared Kotlin object that acts as a reactive bridge between native tap handlers and your Compose NavController.</p><h3>Step 1: The Shared Interface 🤝</h3><p>Let’s start in commonMain. Everything our shared business logic or ViewModels will ever touch lives here.</p><pre>// commonMain/notification/NotificationManager.kt<br>enum class NotificationPermissionStatus {<br>    GRANTED, DENIED, NOT_DETERMINED<br>}<br>data class NotificationAction(<br>    val screen: String,<br>    val data: Map&lt;String, String&gt; = emptyMap()<br>)<br>interface NotificationManager {<br>    suspend fun requestPermission(): Boolean<br>    suspend fun checkPermissionStatus(): NotificationPermissionStatus<br>    suspend fun showNotification(<br>        id: String = generateId(),<br>        title: String,<br>        body: String,<br>        action: NotificationAction? = null<br>    )<br>    suspend fun cancelNotification(id: String)<br>    suspend fun cancelAllNotifications()<br>}<br>expect class NotificationFactory {<br>    fun create(): NotificationManager<br>}<br>internal expect fun generateId(): String</pre><p>NotificationAction carries our deep link information: which screen to open and any extra key-value payloads.</p><blockquote><em>💡 </em><strong><em>Pro Tip:</em></strong><em> The </em><em>screen parameter is a plain </em><em>String here for simplicity. In a production app, consider using a type-safe approach or a sealed class instead of magic strings like </em><em>&quot;notification_detail&quot;. You&#39;ll thank yourself when your codebase grows!</em></blockquote><h3>Step 2: The Navigation Bridge 🌉</h3><p>Before we touch any platform code, let’s build the shared piece that handles the “user tapped a notification → navigate somewhere” flow.</p><pre>// commonMain/notification/NotificationNavigator.kt<br>import kotlinx.coroutines.channels.Channel<br>import kotlinx.coroutines.flow.Flow<br>import kotlinx.coroutines.flow.receiveAsFlow<br><br>object NotificationNavigator {<br>    private val channel = Channel&lt;NotificationAction&gt;(Channel.BUFFERED)<br>    val events: Flow&lt;NotificationAction&gt; = channel.receiveAsFlow()<br>    fun navigate(action: NotificationAction) {<br>        channel.trySend(action)<br>    }<br>}</pre><p>The Channel.BUFFERED configuration is our secret weapon here. If a user taps a notification while the app is completely closed (a cold start scenario), native iOS and Android components will catch the event and fire it before Compose even finishes its first frame. The buffer queues this event up and holds it until a collector in our UI finally subscribes. No dropped events, no broken deep links!</p><h3>Step 3: Android Implementation 🤖</h3><p>Android needs a few things: a notification channel (mandatory since API 26), a PendingIntent to reopen or bring the app to the foreground, and runtime permission handling for API 33+.</p><pre>// androidMain/notification/NotificationManager.android.kt<br>import android.Manifest<br>import android.app.NotificationChannel<br>import android.app.NotificationManager as AndroidSystemNotificationManager<br>import android.app.PendingIntent<br>import android.content.Context<br>import android.content.Intent<br>import android.content.pm.PackageManager<br>import android.os.Build<br>import androidx.core.app.ActivityCompat<br>import androidx.core.app.NotificationCompat<br>import androidx.core.app.NotificationManagerCompat<br>import androidx.core.content.ContextCompat<br>import java.util.UUID<br><br>actual class NotificationFactory(private val context: Context) {<br>    actual fun create(): NotificationManager = AndroidNotificationManager(context)<br>}<br>internal actual fun generateId(): String = UUID.randomUUID().toString()<br>class AndroidNotificationManager(private val context: Context) : NotificationManager {<br>    private val notificationManagerCompat get() = NotificationManagerCompat.from(context)<br>    init { <br>        createNotificationChannel() <br>    }<br>    override suspend fun requestPermission(): Boolean {<br>        if (Build.VERSION.SDK_INT &lt; Build.VERSION_CODES.TIRAMISU) return true<br>        if (isGranted) return true<br>        return NotificationPermissionController.requestPermission?.invoke() ?: false<br>    }<br>    override suspend fun checkPermissionStatus(): NotificationPermissionStatus {<br>        if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.TIRAMISU) {<br>            return when {<br>                isGranted -&gt; NotificationPermissionStatus.GRANTED<br>                NotificationPermissionController.shouldShowRationale?.invoke() == true -&gt;<br>                    NotificationPermissionStatus.DENIED<br>                else -&gt; NotificationPermissionStatus.NOT_DETERMINED<br>            }<br>        }<br>        return if (notificationManagerCompat.areNotificationsEnabled())<br>            NotificationPermissionStatus.GRANTED<br>        else NotificationPermissionStatus.DENIED<br>    }<br>    override suspend fun showNotification(<br>        id: String, title: String, body: String, action: NotificationAction?<br>    ) {<br>        if (checkPermissionStatus() != NotificationPermissionStatus.GRANTED) return<br>        val intent = Intent(context, context.packageManager.getLaunchIntentForPackage(context.packageName)?.component?.className?.let { Class.forName(it) }).apply {<br>            flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP<br>            action?.let {<br>                putExtra(EXTRA_NOTIFICATION_SCREEN, it.screen)<br>                putExtra(EXTRA_NOTIFICATION_ID, id)<br>                it.data.forEach { (key, value) -&gt; putExtra(key, value) }<br>            }<br>        }<br>        val pendingIntent = PendingIntent.getActivity(<br>            context, id.hashCode(), intent,<br>            PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE<br>        )<br>        val notification = NotificationCompat.Builder(context, CHANNEL_ID)<br>            .setSmallIcon(android.R.drawable.ic_dialog_info) <br>            .setContentTitle(title)<br>            .setContentText(body)<br>            .setPriority(NotificationCompat.PRIORITY_HIGH)<br>            .setAutoCancel(true)<br>            .setContentIntent(pendingIntent)<br>            .build()<br>        notificationManagerCompat.notify(id.hashCode(), notification)<br>    }<br>    override suspend fun cancelNotification(id: String) {<br>        notificationManagerCompat.cancel(id.hashCode())<br>    }<br>    override suspend fun cancelAllNotifications() {<br>        notificationManagerCompat.cancelAll()<br>    }<br>    private fun createNotificationChannel() {<br>        if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.O) {<br>            val channel = NotificationChannel(<br>                CHANNEL_ID, &quot;App Notifications&quot;, <br>                AndroidSystemNotificationManager.IMPORTANCE_HIGH<br>            )<br>            context.getSystemService(AndroidSystemNotificationManager::class.java)<br>                .createNotificationChannel(channel)<br>        }<br>    }<br>    companion object {<br>        private const val CHANNEL_ID = &quot;app_notifications&quot;<br>        const val EXTRA_NOTIFICATION_SCREEN = &quot;notification_screen&quot;<br>        const val EXTRA_NOTIFICATION_ID = &quot;notification_id&quot;<br>    }<br>    private val isGranted get() = ContextCompat.checkSelfPermission(<br>        context, Manifest.permission.POST_NOTIFICATIONS<br>    ) == PackageManager.PERMISSION_GRANTED<br>}</pre><h3>Step 4: Android Permission Bridge 🔐</h3><p>There’s a classic architectural puzzle here: our AndroidNotificationManager lives safely inside the Application context. However, launching the runtime permission dialog (POST_NOTIFICATIONS on Android 13+) explicitly requires an Activity context. We need a way to communicate across boundaries.</p><p><em>Enter pragmatic engineering:</em> We’ll establish a global mutable controller. It might not be the textbook architectural approach, but for a single-Activity app, it is an incredibly robust, zero-boilerplate solution. We’ll talk about how to make it super elegant in the potential pitfalls section, I promise!</p><pre>// androidMain/notification/NotificationPermissionController.kt<br>import kotlinx.coroutines.CompletableDeferred<br><br>object NotificationPermissionController {<br>    var requestPermission: (suspend () -&gt; Boolean)? = null<br>    var shouldShowRationale: (() -&gt; Boolean)? = null<br>}</pre><p>Now, let’s wire this controller into your MainActivity so it registers during onCreate and cleans up during onDestroy:</p><pre>// androidMain/MainActivity.kt<br>import android.content.Intent<br>import android.os.Bundle<br>import androidx.activity.ComponentActivity<br>import androidx.activity.compose.setContent<br>import androidx.activity.result.contract.ActivityResultContracts<br>import androidx.core.app.ActivityCompat<br>import kotlinx.coroutines.CompletableDeferred<br><br>class MainActivity : ComponentActivity() {<br>    private var permissionDeferred: CompletableDeferred&lt;Boolean&gt;? = null<br>    private val permissionLauncher = registerForActivityResult(<br>        ActivityResultContracts.RequestPermission()<br>    ) { granted -&gt;<br>        permissionDeferred?.complete(granted)<br>        permissionDeferred = null<br>    }<br>    override fun onCreate(savedInstanceState: Bundle?) {<br>        super.onCreate(savedInstanceState)<br>        NotificationPermissionController.requestPermission = {<br>            val deferred = CompletableDeferred&lt;Boolean&gt;()<br>            permissionDeferred = deferred<br>            permissionLauncher.launch(android.Manifest.permission.POST_NOTIFICATIONS)<br>            deferred.await()<br>        }<br>        <br>        NotificationPermissionController.shouldShowRationale = {<br>            ActivityCompat.shouldShowRequestPermissionRationale(<br>                this, android.Manifest.permission.POST_NOTIFICATIONS<br>            )<br>        }<br>        handleNotificationIntent(intent)<br>        setContent { App() }<br>    }<br>    override fun onNewIntent(intent: Intent) {<br>        super.onNewIntent(intent)<br>        setIntent(intent)<br>        handleNotificationIntent(intent)<br>    }<br>    override fun onDestroy() {<br>        NotificationPermissionController.requestPermission = null<br>        NotificationPermissionController.shouldShowRationale = null<br>        super.onDestroy()<br>    }<br>    private fun handleNotificationIntent(intent: Intent) {<br>        val screen = intent.getStringExtra(<br>            AndroidNotificationManager.EXTRA_NOTIFICATION_SCREEN<br>        ) ?: return<br>        val notificationId = intent.getStringExtra(AndroidNotificationManager.EXTRA_NOTIFICATION_ID)<br>        NotificationNavigator.navigate(<br>            NotificationAction(<br>                screen = screen,<br>                data = buildMap { notificationId?.let { put(&quot;notification_id&quot;, it) } }<br>            )<br>        )<br>    }<br>}</pre><p>onNewIntent handles cases where the app is already running and the user taps a fresh notification banner onCreate captures cold starts when the app is launched entirely from scratch by tapping a notification.</p><p>⚠️ <strong>Critical Configuration:</strong> Don’t forget to add android:launchMode=&quot;singleTop&quot; to your MainActivity in AndroidManifest.xml. Without it, tapping a notification while the app is active will recreate the entire Activity from scratch, resetting your states and dropping navigation routing arguments!</p><pre>&lt;activity<br>  android:name=&quot;.MainActivity&quot;<br>  android:exported=&quot;true&quot;<br>  android:launchMode=&quot;singleTop&quot;&gt;<br>&lt;/activity&gt;</pre><h3>Step 5: iOS Implementation 🍎</h3><p>iOS uses UNUserNotificationCenter, which has been the unified way to handle local and remote notifications since iOS 10.</p><pre>// iosMain/notification/NotificationManager.ios.kt<br>import platform.Foundation.NSUUID<br>import platform.UserNotifications.UNAuthorizationOptionAlert<br>import platform.UserNotifications.UNAuthorizationOptionBadge<br>import platform.UserNotifications.UNAuthorizationOptionSound<br>import platform.UserNotifications.UNAuthorizationStatusAuthorized<br>import platform.UserNotifications.UNAuthorizationStatusDenied<br>import platform.UserNotifications.UNMutableNotificationContent<br>import platform.UserNotifications.UNNotificationRequest<br>import platform.UserNotifications.UNNotificationSound<br>import platform.UserNotifications.UNNotificationTrigger<br>import platform.UserNotifications.UNTimeIntervalNotificationTrigger<br>import platform.UserNotifications.UNUserNotificationCenter<br>import kotlin.coroutines.resume<br>import kotlinx.coroutines.suspendCancellableCoroutine<br><br>actual class NotificationFactory {<br>    actual fun create(): NotificationManager = IosNotificationManager()<br>}<br>internal actual fun generateId(): String = NSUUID.UUID().UUIDString()<br>class IosNotificationManager : NotificationManager {<br>    private val center get() = UNUserNotificationCenter.currentNotificationCenter()<br>    override suspend fun requestPermission(): Boolean = suspendCancellableCoroutine { cont -&gt;<br>        center.requestAuthorizationWithOptions(<br>            options = UNAuthorizationOptionAlert or UNAuthorizationOptionSound or UNAuthorizationOptionBadge<br>        ) { granted, error -&gt;<br>            cont.resume(granted &amp;&amp; error == null)<br>        }<br>    }<br>    override suspend fun checkPermissionStatus(): NotificationPermissionStatus =<br>        suspendCancellableCoroutine { cont -&gt;<br>            center.getNotificationSettingsWithCompletionHandler { settings -&gt;<br>                val status = when (settings?.authorizationStatus) {<br>                    UNAuthorizationStatusAuthorized -&gt; NotificationPermissionStatus.GRANTED<br>                    UNAuthorizationStatusDenied -&gt; NotificationPermissionStatus.DENIED<br>                    else -&gt; NotificationPermissionStatus.NOT_DETERMINED<br>                }<br>                cont.resume(status)<br>            }<br>        }<br>    override suspend fun showNotification(<br>        id: String, title: String, body: String, action: NotificationAction?<br>    ) {<br>        val content = UNMutableNotificationContent().apply {<br>            setTitle(title)<br>            setBody(body)<br>            setSound(UNNotificationSound.defaultSound())<br>            action?.let { act -&gt;<br>                val userInfo = mutableMapOf&lt;Any?, Any?&gt;(<br>                    &quot;screen&quot; to act.screen,<br>                    &quot;notification_id&quot; to id<br>                )<br>                act.data.forEach { (key, value) -&gt; userInfo[key] = value }<br>                setUserInfo(userInfo as Map&lt;Any?, *&gt;)<br>            }<br>        }<br>        val trigger = UNTimeIntervalNotificationTrigger.triggerWithTimeInterval(<br>            timeInterval = 0.1,<br>            repeats = false<br>        )<br>        val request = UNNotificationRequest.requestWithIdentifier(<br>            identifier = id,<br>            content = content,<br>            trigger = trigger<br>        )<br>        suspendCancellableCoroutine&lt;Unit&gt; { cont -&gt;<br>            center.addNotificationRequest(request) { error -&gt;<br>                cont.resume(Unit)<br>            }<br>        }<br>    }<br>    override suspend fun cancelNotification(id: String) {<br>        center.removeDeliveredNotificationsWithIdentifiers(listOf(id))<br>    }<br>    override suspend fun cancelAllNotifications() {<br>        center.removeAllDeliveredNotifications()<br>    }<br>}</pre><blockquote><strong><em>Dev Note:</em></strong><em> Yes, that </em><em>0.1 second trigger is a deliberate, shameless workaround. By default, iOS explicitly hides notification banners when the app is actively running in the foreground. This tiny delay tricks iOS into scheduling it properly as a system event. It keeps our demo code clean, but don&#39;t show this trick to your iOS tech lead without a warm coffee in hand!</em></blockquote><h3>Step 6: iOS Swift Bridge 🌉</h3><p>When a user taps an iOS notification banner, the native OS fires a callback directly into Swift’s AppDelegate. We need an entry point to pass this event into Kotlin.</p><p>First, write a simple Kotlin function inside iosMain:</p><pre>// iosMain/notification/IosNotificationBridge.kt<br>fun handleNotificationTap(screen: String, data: Map&lt;String, String&gt;) {<br>    NotificationNavigator.navigate(NotificationAction(screen = screen, data = data))<br>}</pre><p>Next, open Xcode and implement UNUserNotificationCenterDelegate within your Swift project:</p><pre>// iosApp/AppDelegate.swift<br>import UserNotifications<br>import ComposeApp<br><br>class AppDelegate: NSObject, UIApplicationDelegate, UNUserNotificationCenterDelegate {<br>    func application(<br>        _ application: UIApplication,<br>        didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil<br>    ) -&gt; Bool {<br>        UNUserNotificationCenter.current().delegate = self<br>        return true<br>    }<br>    // Fired when a user taps the notification banner<br>    func userNotificationCenter(<br>        _ center: UNUserNotificationCenter,<br>        didReceive response: UNNotificationResponse,<br>        withCompletionHandler completionHandler: @escaping () -&gt; Void<br>    ) {<br>        let userInfo = response.notification.request.content.userInfo<br>        let screen = userInfo[&quot;screen&quot;] as? String ?? &quot;&quot;<br>        let notificationId = userInfo[&quot;notification_id&quot;] as? String ?? &quot;&quot;<br>        IosNotificationBridgeKt.handleNotificationTap(<br>            screen: screen,<br>            data: [&quot;notification_id&quot;: notificationId]<br>        )<br>        completionHandler()<br>    }<br>}</pre><p>Don’t forget to assign this delegate class inside your main iOSApp.swift entry file:</p><pre>// iosApp/iOSApp.swift<br>import SwiftUI<br>import ComposeApp<br><br>@main<br>struct iOSApp: App {<br>    @UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate<br>    <br>    var body: some Scene {<br>        WindowGroup {<br>            ContentView()<br>        }<br>    }<br>}</pre><h3>Step 7: Wiring Navigation in Compose 🧭</h3><p>Both native sides are now successfully streaming events into NotificationNavigator. Now, our shared Compose code simply needs to listen and execute navigation commands:</p><pre>// commonMain/app/App.kt<br>import androidx.compose.runtime.Composable<br>import androidx.compose.runtime.LaunchedEffect<br>import androidx.navigation.compose.NavHost<br>import androidx.navigation.compose.composable<br>import androidx.navigation.compose.rememberNavController<br><br>@Composable<br>fun App() {<br>    MaterialTheme {<br>        val navController = rememberNavController()<br>        LaunchedEffect(navController) {<br>            NotificationNavigator.events.collect { action -&gt;<br>                when (action.screen) {<br>                    &quot;notification_detail&quot; -&gt; navController.navigate(<br>                        Route.NotificationDetail(<br>                            notificationId = action.data[&quot;notification_id&quot;] ?: &quot;&quot;,<br>                            title = &quot;From Notification&quot;,<br>                            message = &quot;Opened via notification deep link!&quot;<br>                        )<br>                    )<br>                }<br>            }<br>        }<br>        NavHost(navController = navController, startDestination = Route.MainGraph) {<br>            // Define your standard NavHost graphs and composables here...<br>        }<br>    }<br>}</pre><h3>Step 8: Dependency Injection with Koin 🛠️</h3><p>Let’s register our modules so they can be injected effortlessly across our ViewModels:</p><pre>// commonMain/Modules.kt<br>val sharedModule = module {<br>    single { get&lt;NotificationFactory&gt;().create() }<br>    viewModelOf(::HomeViewModel)<br>}<br><br>// androidMain/Modules.android.kt<br>actual val platformModule = module {<br>    single { NotificationFactory(androidContext()) }<br>}<br><br>// iosMain/Modules.ios.kt<br>actual val platformModule = module {<br>    single { NotificationFactory() }<br>}</pre><h3>Step 9: Usage from ViewModels 🚀</h3><p>Now, calling notifications from anywhere in your platform-agnostic business logic is beautifully clean:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FSqtramZqFSI%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fshorts%2FSqtramZqFSI%3Ffeature%3Dshare&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FSqtramZqFSI%2Fhq2.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/cfdb6228f3b779568d20772db9d86bed/href">https://medium.com/media/cfdb6228f3b779568d20772db9d86bed/href</a></iframe><h3>Things Worth Knowing Before You Ship ⚠️</h3><p>While this system serves as a great, reliable production foundation, keep these architectural trade-offs in mind:</p><ul><li><strong>Global Permission Controllers Leak Context:</strong> NotificationPermissionController holds temporary references to the active Activity. If an Android process gets aggressively killed or closed, those references could leak. For massive enterprise applications, consider binding this bridge to an active Koin Activity Scope.</li><li><strong>Global Singletons Limit Testing:</strong> NotificationNavigator is defined directly as a Kotlin object. This can make concurrent unit testing difficult. For larger applications, inject it via Koin as a true single singleton instance instead.</li><li><strong>The iOS Foreground Presentation Illusion:</strong> Our 0.1s trigger delay works perfectly for demos. However, for a production iOS application, you should properly implement UNUserNotificationCenterDelegate.willPresent in Swift to determine whether a banner should slide down when the app is active in the foreground.</li></ul><h3>Conclusion 🏁</h3><p>We’ve officially built a complete, cross-platform local notification architecture from scratch using Compose Multiplatform. The expect/actual pattern proves its incredible value once again: your ViewModels don’t know or care which operating system they are currently running on, and heavy native platform complexities remain safely encapsulated behind a clean interface.</p><p>Don’t forget to check out the previous parts of this architectural series where we set up <strong>Firebase Remote Config</strong> and <strong>Amplitude Analytics</strong> to complete your enterprise-ready KMP template!</p><p>Happy coding, and let your notifications always land smoothly! 🚀 Also, feel free to connect with me on <a href="https://www.linkedin.com/in/vitalii-voitenko/">LinkedIn</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=92a2d87374fb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What your users really want: Tracking behavior in KMP projects using Amplitude ]]></title>
            <link>https://medium.com/@Vetal_3534/what-your-users-really-want-tracking-behavior-in-kmp-projects-using-amplitude-8c983b8e69c5?source=rss-ebca308e14eb------2</link>
            <guid isPermaLink="false">https://medium.com/p/8c983b8e69c5</guid>
            <category><![CDATA[jetpack-compose]]></category>
            <category><![CDATA[kotlin-multiplatform]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[amplitude]]></category>
            <dc:creator><![CDATA[Vitalii Voitenko]]></dc:creator>
            <pubDate>Mon, 02 Mar 2026 15:41:24 GMT</pubDate>
            <atom:updated>2026-03-02T15:41:24.542Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EXFOYgGfH2sSDKHhZCUT1g.jpeg" /></figure><p>In the real world, it doesn’t matter how “killer” your new feature is or how cool your onboarding design looks. Users are unpredictable. They often ignore the “obvious” paths, get stuck in unexpected places, or use your app in ways you never even imagined. To stop guessing and start seeing the real UI/UX picture, we use <strong>event tracking services</strong>. <a href="https://amplitude.com/"><strong>Amplitude</strong></a> is a powerful tool that helps you collect user events, build funnels, and do other cool things like <strong>session replay</strong> (but that’s a <strong>different story</strong> =). It turns raw data into insights, helping you understand what your users actually need. In this article, we’ll dive into how to integrate Amplitude into a <strong>Kotlin Multiplatform (KMP)</strong> project and make it work seamlessly for both Android and iOS.<br>In the <a href="https://medium.com/@Vetal_3534/how-to-connect-firebase-remote-config-to-a-compose-multiplatform-app-a-step-by-step-guide-d75f79d257d4"><strong>previous article</strong></a>, we covered how to manage app behavior on the “fly” using <strong>Firebase Remote Config</strong>. Now, it’s time to track what happens after those changes are live.</p><h3>What’s inside:</h3><ul><li><strong>Console Setup:</strong> Creating a project and getting your API keys.</li><li><strong>Project Structure:</strong> Organizing your KMP modules.</li><li><strong>Dependency Injection:</strong> Setting up <strong>Koin</strong> for shared and platform-specific logic.</li><li><strong>The Multiplatform Bridge:</strong> Implementing the expect/actual pattern for Amplitude SDKs.</li><li><strong>Analytics Repository:</strong> Creating a clean, unified API for event tracking.</li><li><strong>Verification:</strong> Testing the flow in the Amplitude dashboard.</li></ul><h3>Step 1: Setting up the Amplitude Console ⚙️</h3><p>First things first, you’ll need an <strong>Amplitude account</strong>. They offer a generous free plan, which is perfect for small projects or your pet project. The first step is to create a project for your applications.</p><p>Navigate to: <strong>Settings -&gt; Projects -&gt; Create Project</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fTP2IWO0R-WSSuB7nDpcBw.png" /></figure><p>Give your project a name, hit <strong>Create</strong>, and wait a few seconds… Done! Now, we need to add the <strong>Sources — </strong>this is where Amplitude will receive events from.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yTMWDpsyvDboIlA0JGPPzw.png" /></figure><h4>Adding Android and iOS Sources</h4><p>Start by selecting <strong>Android</strong> and enter your app’s name.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*phF5pAdyRsrLnVvPQY-3Ew.png" /></figure><p>Once created, you’ll see an instruction page for the native Android SDK. You can skip the code for now — what we really need is <strong>API Key</strong>. We’ll use this later during the Amplitude initialization in our Kotlin code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jMhAgmNc08Gy4sr8X0h8nQ.png" /></figure><p>For <strong>iOS</strong>, the flow is identical. Choose the <strong>iOS SDK</strong> and follow the same steps.</p><blockquote><strong><em>Tip:</em></strong><em> API Key will be the same for both Android and iOS within the same project, so you don’t need to save two different strings. One key to rule them all!</em></blockquote><p>Now that we have our credentials, let’s jump into Android Studio and start coding.</p><h3>Project Structure</h3><p>To make sure we’re on the same page, here is what a standard KMP project structure looks like:</p><pre><br>Root Project (MyKMPApp)<br>├── composeApp/ # Main module containing the application code<br>│   ├── src/<br>│   │   ├── commonMain/ # All shared code (UI, Logic, ViewModels)<br>│   │   │   ├── kotlin/<br>│   │   │   │   └── org.example.project/<br>│   │   │   │       ├── App.kt # Entry point for Compose UI<br>│   │   │   └── composeResources/ # Shared resources (strings, images, fonts)<br>│   │   │<br>│   │   ├── androidMain/ # Android-specific code<br>│   │   │   ├── kotlin/<br>│   │   │   └── AndroidManifest.xml<br>│   │   │<br>│   │   └── iosMain/ # iOS-specific code (e.g., Platform.ios.kt)<br>│   │       └── kotlin/<br>│   │<br>│   └── build.gradle.kts # CMP module and dependency configuration<br>│<br>├── iosApp/ # Xcode project (Swift wrapper for iOS)<br>│   ├── iosApp/<br>│   │   ├── AppDelegate.swift<br>│   │   └── ContentView.swift # Calls Compose via ComposeUIViewController<br>│   └── iosApp.xcodeproj<br>│<br>├── gradle/ # Gradle configuration <br>|   ├── libs.versions.toml #libs.versions.toml<br>├── build.gradle.kts # Root build script<br>└── settings.gradle.kts # Module inclusion script</pre><h3>Step 2: Setting up Dependency Injection (Koin) 🛠️</h3><p>Since the Amplitude SDK for Android requires a Context, we need a way to provide it cleanly across our multiplatform modules. This is where <strong>Koin</strong> comes in.</p><p>I’ll use Koin for this project because it’s lightweight, has native support for Compose Multiplatform (CMP), and it will save our time with platform-specific dependencies. We won’t spend too much time on the basics, but here is the common setup.</p><h4>1. Add Dependencies</h4><p>Open your libs.versions.toml and add:</p><pre>[versions]<br>koin = &quot;4.1.0&quot;<br>[libraries]<br>koin-android = { module = &quot;io.insert-koin:koin-android&quot;, version.ref = &quot;koin&quot; }<br>koin-androidx-compose = { module = &quot;io.insert-koin:koin-androidx-compose&quot;, version.ref = &quot;koin&quot; }<br>koin-core = { module = &quot;io.insert-koin:koin-core&quot;, version.ref = &quot;koin&quot; }<br>koin-compose = { module = &quot;io.insert-koin:koin-compose&quot;, version.ref = &quot;koin&quot; }<br>koin-compose-viewmodel = { module = &quot;io.insert-koin:koin-compose-viewmodel&quot;, version.ref = &quot;koin&quot; }</pre><p>In your composeApp/build.gradle.kts, add them to the respective source sets:</p><pre>sourceSets {<br>  androidMain.dependencies {<br>    ....................<br>    implementation(libs.koin.android)<br>    implementation(libs.koin.androidx.compose)<br>    ....................<br>  }<br>  commonMain.dependencies {<br>    ....................<br>    implementation(libs.koin.compose)<br>    implementation(libs.koin.compose.viewmodel)<br>    api(libs.koin.core)<br>    ....................<br>  }<br>}</pre><h4>2. Define the Modules</h4><p>Sync the project. Now, in commonMain, create Module.kt. This will eventually hold all our repositories, ViewModels, and network logic.</p><pre>expect val platformModule: Module<br>val sharedModule = module { /* Future dependencies go here */}</pre><p>To create the platform-specific implementations, use the IDE’s magic: place your cursor on platformModule, press <strong>Option + Enter</strong> (Alt + Enter), and select <strong>&quot;Create missing actuals&quot;</strong>. This will generate:</p><ul><li>iosMain/.../Modules.ios.kt</li><li>androidMain/.../Modules.android.kt</li></ul><h4>3. Initialize Koin</h4><p>In commonMain, create InitKoin.kt to set up DI framework</p><pre>fun initKoin(config: KoinAppDeclaration? = null) {<br>  startKoin {<br>    config?.invoke(this)<br>    modules(sharedModule, platformModule)<br>  }<br>}</pre><p>Now, we need to trigger this initialization on both sides:</p><ul><li><strong>Android:</strong> Create a BaseApplication in androidMain, register it in AndroidManifest.xml (android:name=&quot;.BaseApplication&quot;), and pass the context.</li></ul><pre>class BaseApplication: Application() {<br>  override fun onCreate() {<br>    super.onCreate()<br>    initKoin {<br>      androidContext(this@BaseApplication)<br>    }<br>  }<br>}</pre><ul><li><strong>iOS:</strong> Update your MainViewController.kt:</li></ul><pre>fun MainViewController() = ComposeUIViewController(<br>  configure = {<br>      initKoin()<br>    }<br>) {<br>    App()<br>}</pre><h3>Step 3: Integrating Amplitude SDKs 📈</h3><p>The infrastructure is ready! Now let’s add the Amplitude dependencies.</p><p>For <strong>Android</strong>, add this to libs.versions.toml:</p><pre>[versions]<br>amplitude-android = &quot;1.22.2&quot;<br><br>[libraries]<br>amplitude-android = { module = &quot;com.amplitude:analytics-android&quot;, version.ref = &quot;amplitude-android&quot; }</pre><p>For <strong>iOS</strong>, we’ll use <strong>CocoaPods</strong>. In your composeApp/build.gradle.kts, add the pod dependency:</p><pre>cocoapods {<br>  summary = &quot;My compose multiplatform app&quot;<br>  version = &quot;1.0&quot;<br>  homepage = &quot;https://medium.com&quot;<br>  ios.deploymentTarget = &quot;16.0&quot;<br>  <br>  framework {<br>      baseName = &quot;ComposeApp&quot;<br>      isStatic = true<br>  }<br>  pod(&quot;Amplitude&quot;) {<br>      version = &quot;~&gt; 8.20.0&quot;<br>      extraOpts += listOf(&quot;-compiler-option&quot;, &quot;-fmodules&quot;)<br>  }<br>}</pre><p>After syncing, run these commands in your terminal. This ‘clean’ sequence is a lifesaver if you’ve ever run into <strong>dependency conflicts</strong> on the iOS side — it ensures your Pods are fresh and correctly linked.</p><pre>rm -rf iosApp/Pods  <br>rm -rf iosApp/Podfile.lock<br>rm -rf ~/.cocoapods/repos<br>pod repo update<br>./gradlew podInstall<br><br><br>cd/iosApp/<br>pod install --repo-update</pre><p>Congratulations! The dependencies are in place. Now we are ready to write some actual tracking logic!</p><h3>Step 4: Bridging the Platforms (Expect/Actual) 🌉</h3><p>Now for the fun part. We need to create a unified interface in commonMain so our shared code doesn&#39;t care whether it’s running on a Android or an iPhone.</p><p>In composeApp/commonMain, create an interface AmplitudeAnalytics and an expect class AmplitudeFactory:</p><pre>/**<br> * Core interface for analytics. <br> * It abstracts the native Android and iOS SDK implementations.<br> */<br>interface AmplitudeAnalytics {<br>    /**<br>     * The most important method. It starts the engine.<br>     * @param apiKey your project key from the Amplitude dashboard.<br>     * @param userId unique identifier for the user (if known).<br>     * @param optOut if true, disables tracking (crucial for GDPR/privacy compliance).<br>     */<br>    fun initialize(apiKey: String, userId: String?, optOut: Boolean = false)<br><br>    /**<br>     * Helper methods to retrieve system IDs from Amplitude. <br>     * Useful for debugging or cross-referencing with other services.<br>     */<br>    fun getDeviceId(): String<br>    fun getSessionId(): Long<br><br>    /**<br>     * Records a specific action performed by user.<br>     * @param eventName The name of the action (e.g., &quot;button_clicked&quot;).<br>     * @param properties Metadata related to the event (e.g., price, category).<br>     */<br>    fun sendEvent(eventName: String, properties: Map&lt;String, Any&gt;? = null)<br>    <br>    /**<br>     * Updates User Properties. <br>     * Used to &quot;tag&quot; a user (e.g., setting &quot;is_premium&quot; to true).<br>     */<br>    fun identify(property: String, value: Boolean)<br><br>    /**<br>     * Custom method to log errors as events for better monitoring.<br>     */<br>    fun sendEventError(eventName: String, value: Map&lt;String, Any&gt;? = null)<br><br>    /**<br>     * Sets or updates the User ID during the session.<br>     */<br>    fun setUserId(userId: String)<br>}<br><br>expect class AmplitudeFactory {<br>    fun create(): AmplitudeAnalytics<br>}</pre><p>Now, let’s use the IDE shortcut (<strong>Option + Enter</strong> on the factory name) to generate the “missing actuals”.</p><h4>Android Implementation (androidMain) 🤖</h4><p>On Android, we need to pass the Context to the Amplitude SDK. We also add a small helper to enable debug logging only for development builds.</p><pre>// AmplitudeAnalytics.android.kt<br>import android.content.Context<br>import com.amplitude.android.Amplitude<br>import com.amplitude.android.Configuration<br>import com.amplitude.android.DefaultTrackingOptions<br>import com.amplitude.common.Logger<br>import com.amplitude.android.events.Identify<br><br>actual class AmplitudeFactory(<br>    private val context: Context<br>) {<br>    actual fun create(): AmplitudeAnalytics {<br>        return AndroidAmplitudeAnalytics(context)<br>    }<br>}<br><br>class AndroidAmplitudeAnalytics(<br>    private val context: Context<br>) : AmplitudeAnalytics {<br><br>    private var amplitude: Amplitude? = null<br><br>    override fun initialize(apiKey: String, userId: String?, optOut: Boolean) {<br>        amplitude = Amplitude(<br>            Configuration(<br>                context = context.applicationContext,<br>                apiKey = apiKey,<br>                defaultTracking = DefaultTrackingOptions.ALL,<br>                optOut = optOut<br>            )<br>        ).apply {<br>            userId?.let { setUserId(it) }<br>            // Enable logging only for debug builds to keep production logs clean<br>            logger.logMode = if (isDebugBuild()) {<br>                Logger.LogMode.DEBUG<br>            } else {<br>                Logger.LogMode.OFF<br>            }<br>        }<br>    }<br><br>    override fun getDeviceId(): String =<br>        amplitude?.getDeviceId() ?: &quot;&quot;<br><br>    override fun getSessionId(): Long =<br>        amplitude?.sessionId ?: 0L<br><br>    override fun sendEvent(eventName: String, properties: Map&lt;String, Any&gt;?) {<br>        amplitude?.track(eventName, properties)<br>    }<br><br>    override fun identify(property: String, value: Boolean) {<br>        val identify = Identify().setOnce(property, value)<br>        amplitude?.identify(identify)<br>    }<br><br>    override fun sendEventError(eventName: String, value: Map&lt;String, Any&gt;?) {<br>        amplitude?.track(eventName, value)<br>    }<br><br>    override fun setUserId(userId: String) {<br>        amplitude?.setUserId(userId)<br>    }<br><br>    private fun isDebugBuild(): Boolean {<br>        return context.applicationInfo.flags and<br>                android.content.pm.ApplicationInfo.FLAG_DEBUGGABLE != 0<br>    }<br>}</pre><h4>iOS Implementation (iosMain) 🍎</h4><p>The iOS SDK (via CocoaPods) feels a bit different. The biggest challenge here is that a Kotlin Map doesn&#39;t automatically convert to an iOS NSDictionary. We have to do some manual &quot;mapping&quot; to ensure the Objective-C/Swift side understands our data.</p><blockquote><strong>⚠️ A word of caution:</strong> This mapping method is a “quick and dirty” solution for demo purposes. It is <strong>not very stable</strong> for complex production apps because it doesn’t handle nested collections (like Lists or other Maps) or custom objects. If you plan to send complex data structures to Amplitude, you should refine this logic or use a more robust serialization library.</blockquote><p><strong>💡 Note on Instance Names:</strong> &gt; We use instanceWithName(&quot;default&quot;) to initialize the standard Amplitude instance. For most apps, one instance is all you need. However, if your project requires sending events to multiple Amplitude projects simultaneously, you can create separate instances by giving them unique names (&quot;Production&quot; and &quot;Staging&quot;).</p><pre>// AmplitudeAnalytics.ios.kt<br>import cocoapods.Amplitude.AMPIdentify<br>import cocoapods.Amplitude.Amplitude<br>import kotlinx.cinterop.ExperimentalForeignApi<br>import platform.Foundation.NSDictionary<br>import platform.Foundation.NSNumber<br>import platform.Foundation.dictionaryWithDictionary<br><br>actual class AmplitudeFactory {<br>    actual fun create(): AmplitudeAnalytics {<br>        return IosAmplitudeAnalytics()<br>    }<br>}<br><br>class IosAmplitudeAnalytics : AmplitudeAnalytics {<br>    private var amplitude: Amplitude? = null<br><br>    override fun initialize(apiKey: String, userId: String?, optOut: Boolean) {<br>        // iOS uses instance names to manage different Amplitude instances<br>        amplitude = Amplitude.instanceWithName(&quot;default&quot;).apply {<br>            initializeApiKey(apiKey)<br>            userId?.let { setUserId(it) }<br>            setOptOut(optOut)<br>        }<br>    }<br><br>    override fun getDeviceId(): String =<br>        amplitude?.getDeviceId() ?: &quot;&quot;<br><br>    override fun getSessionId(): Long =<br>        amplitude?.getSessionId() ?: 0L<br><br>    override fun sendEvent(eventName: String, properties: Map&lt;String, Any&gt;?) {<br>        amplitude?.logEvent(<br>            eventName,<br>            withEventProperties = properties?.toNSDictionary() as? Map&lt;Any?, *&gt;<br>        )<br>    }<br><br>    override fun identify(property: String, value: Boolean) {<br>        val identify = AMPIdentify()<br>        identify.setOnce(property, value = NSNumber(bool = value))<br>        amplitude?.identify(identify)<br>    }<br><br>    override fun sendEventError(eventName: String, value: Map&lt;String, Any&gt;?) {<br>        amplitude?.logEvent(<br>            eventName,<br>            withEventProperties = value?.toNSDictionary() as? Map&lt;Any?, *&gt;<br>        )<br>    }<br><br>    override fun setUserId(userId: String) {<br>        amplitude?.setUserId(userId)<br>    }<br><br>    // Helper to convert Kotlin Map to iOS-friendly NSDictionary<br>    private fun Map&lt;String, Any&gt;.toNSDictionary(): NSDictionary {<br>        val mutableDict = mutableMapOf&lt;Any?, Any?&gt;()<br><br>        forEach { (key, value) -&gt;<br>            val convertedValue = when (value) {<br>                is String -&gt; value<br>                is Int -&gt; NSNumber(int = value)<br>                is Long -&gt; NSNumber(longLong = value)<br>                is Double -&gt; NSNumber(double = value)<br>                is Float -&gt; NSNumber(float = value)<br>                is Boolean -&gt; NSNumber(bool = value)// Kotlin Boolean -&gt; Swift Bool (NSNumber)<br>                else -&gt; value.toString()<br>            }<br>            mutableDict[key] = convertedValue<br>        }<br><br>        return NSDictionary.dictionaryWithDictionary(mutableDict as Map&lt;Any?, *&gt;) as NSDictionary<br>    }<br>}</pre><h3>Step 5: The Analytics Repository 🏗️</h3><p>To make our life even easier, let’s wrap everything in a AnalyticsRepository. This class will handle the initialization logic (like passing the API Key) so your ViewModels don&#39;t have to deal with it.</p><p>Create AnalyticsRepository in commonMain:</p><pre>class AnalyticsRepository(<br>    private val amplitude: AmplitudeAnalytics,<br>    private val apiKey: String,<br>    private val getUserId: () -&gt; String,<br>    private val shouldTrackEvents: () -&gt; Boolean<br>) {<br>    init {<br>        amplitude.initialize(<br>            apiKey = apiKey,<br>            userId = getUserId(),<br>            optOut = !shouldTrackEvents()<br>        )<br>    }<br><br>    fun getDeviceId(): String = amplitude.getDeviceId()<br><br>    fun getSessionId(): Long = amplitude.getSessionId()<br><br>    fun sendEvent(eventName: String, properties: Map&lt;String, Any&gt;? = null) {<br>        amplitude.sendEvent(eventName, properties)<br>    }<br><br>    fun identify(property: String, value: Boolean) {<br>        amplitude.identify(property, value)<br>    }<br><br>    fun sendEventError(eventName: String, value: Map&lt;String, Any&gt;? = null) {<br>        amplitude.sendEventError(eventName, value)<br>    }<br><br>    fun updateUserId(userId: String) {<br>        amplitude.setUserId(userId)<br>    }<br><br>}</pre><h3>Final part: Connecting Koin</h3><p>Now we just need to tell Koin how to create these classes.</p><p>In androidMain/Modules.android.kt:</p><pre>import org.appvithin.cmpsample.analytics.AmplitudeFactory<br>import org.koin.android.ext.koin.androidApplication<br>import org.koin.core.module.Module<br>import org.koin.dsl.module<br> <br>import org.koin.core.module.Module<br>import org.koin.dsl.module<br><br>actual val platformModule: Module<br>    get() = module {<br>        single { AmplitudeFactory() }<br>    }</pre><p>And finally, in commonMain/Module.kt, we put it all together:</p><pre>expect val platformModule: Module<br><br>val sharedModule = module {<br><br>    single { get&lt;AmplitudeFactory&gt;().create() } // Create the platform-specific engine<br>    single {<br>        AnalyticsRepository(<br>            amplitude = get(),<br>            apiKey = &quot;YOU_API_KEY&quot;, <br>            getUserId = { &quot;random_user_id&quot; }, // Replace with real logic later<br>            shouldTrackEvents = { true } <br>        )<br>    }<br><br>    viewModelOf(::HomeViewModel)<br>}</pre><p>And that’s it! Our multiplatform tracking engine is officially under the hood and ready to roar. 🚀</p><h3>Step 6: Putting It Into Action 🚀</h3><p>Now that our engine is ready, let’s fire it up. According to best practices, event tracking should happen in the <strong>ViewModel</strong> layer. This keeps our UI clean and ensures events are triggered by actual logic.</p><p>For this demo, we’ll track a simple app_opened event whenever our HomeViewModel is initialized.</p><pre>class HomeViewModel(<br>    private val analyticsRepository: AnalyticsRepository<br>): ViewModel() {<br><br>    init {<br>        analyticsRepository.sendEvent(<br>            eventName = &quot;app_opened&quot;<br>        )<br>    }<br>}</pre><h3>Testing and Verification</h3><p>To see the data in Amplitude, we need to provide a unique userId. In a real app, you’d use a persistent ID (like one from your database or local storage). For testing purposes, we can generate a random UUID:</p><pre>single {<br>        // Helper method for generated random UUID<br>        fun randomUUID(): String {<br>            return buildString(36) {<br>                repeat(8) { append(Random.nextInt(16).toString(16)) }<br>                append(&#39;-&#39;)<br>                repeat(4) { append(Random.nextInt(16).toString(16)) }<br>                append(&#39;-&#39;)<br>                append(&#39;4&#39;)<br>                repeat(3) { append(Random.nextInt(16).toString(16)) }<br>                append(&#39;-&#39;)<br>                append((Random.nextInt(4) or 8).toString(16))<br>                repeat(3) { append(Random.nextInt(16).toString(16)) }<br>                append(&#39;-&#39;)<br>                repeat(12) { append(Random.nextInt(16).toString(16)) }<br>            }<br>        }<br>        AnalyticsRepository(<br>            amplitude = get(),<br>            apiKey = &quot;API_KEY&quot;,<br>            getUserId = { randomUUID() },<br>            shouldTrackEvents = { true } <br>        )<br>    }</pre><blockquote><strong><em>⚠️ Note:</em></strong><em> In a production app, you should save this UUID to the device’s local storage. If you generate a new one every time, Amplitude will treat the same person as a “New User” every time they reopen the app, which will ruin your retention metrics!</em></blockquote><h4>The Moment of Truth</h4><p>Run your app on both an <strong>Android Emulator</strong> and an <strong>iOS Simulator</strong>. After the apps launch, head over to your <strong>Amplitude Dashboard</strong> under the <strong>Home</strong> or <strong>User Look-Up</strong> tab.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/812/1*iYj97xoj1gh9lTicxw9-7Q.png" /></figure><p>In the <strong>Recent Users</strong> widget, you should see your test devices appear. If you click on a specific user, you can dive deep into their activity feed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IOYxuQnWXAJvGz8BNdJl9Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I4bnjM1V6syy-AzObzgRxw.png" /></figure><p>Take a look at the event details:</p><ul><li>The <strong>Red Area</strong> shows the chronological stream of events (our app_opened should be right there).</li><li>The <strong>Blue Area</strong> confirms the metadata: you’ll see different Platforms (Android vs. iOS) and OS versions.</li></ul><h3>Conclusion</h3><p>That’s it! You’ve successfully built a cross-platform analytics engine using <strong>Kotlin Multiplatform</strong> and <strong>Amplitude</strong>. Now you have a single, clean interface to track user behavior across both worlds without duplicating your logic.</p><p>Happy coding, and may your funnels always be green! 📈 Also, feel free to connect with me on <a href="https://www.linkedin.com/in/vitalii-voitenko/">LinkedIn</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8c983b8e69c5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Connect Firebase Remote Config to a Compose Multiplatform App: A Step-by-Step Guide]]></title>
            <link>https://medium.com/@Vetal_3534/how-to-connect-firebase-remote-config-to-a-compose-multiplatform-app-a-step-by-step-guide-d75f79d257d4?source=rss-ebca308e14eb------2</link>
            <guid isPermaLink="false">https://medium.com/p/d75f79d257d4</guid>
            <category><![CDATA[compose-multiplatform]]></category>
            <category><![CDATA[kotlin-multiplatform]]></category>
            <category><![CDATA[firebase]]></category>
            <category><![CDATA[firebase-remote-config]]></category>
            <category><![CDATA[anroid-app]]></category>
            <dc:creator><![CDATA[Vitalii Voitenko]]></dc:creator>
            <pubDate>Mon, 23 Feb 2026 16:37:05 GMT</pubDate>
            <atom:updated>2026-02-23T16:37:05.922Z</atom:updated>
            <content:encoded><![CDATA[<p>This article focuses on one way to connect Firebase Remote Config to a Compose Multiplatform project. Why do we need this? In real-world apps, businesses want to enable new features, show different texts to users, and experiment with onboards or paywalls all without releasing a new version of the app to Google Play or the App Store.</p><p>Firebase Remote Config is perfect for these purposes. It is a tool from Google that allows you to change app settings directly from the cloud.</p><p>In this article, I will show you how to connect Remote Config to a Compose Multiplatform project. <strong>It will work on both Android and iOS using a single codebase.</strong></p><p>I use a simple approach: expect/actual + interface. This way, you can easily replace Firebase with another service in the future. For iOS dependency management, we will be using <strong>CocoaPods</strong> instead of Swift Package Manager</p><p><strong>What you need to get started:</strong></p><ul><li><strong>IDE:</strong> Android Studio + Kotlin Multiplatform plugin.</li><li><strong>Project:</strong> Existing Compose Multiplatform setup (Android &amp; iOS) you can use <a href="https://kmp.jetbrains.com/?android=true&amp;ios=true&amp;iosui=compose&amp;includeTests=true">Kotlin Multiplatform Wizard</a>.</li><li><strong>Account:</strong> Firebase Console access.</li><li><strong>iOS Environment:</strong> Mac with Xcode and CocoaPods installed.</li><li><strong>Knowledge:</strong> A basic understanding of Compose Multiplatform and Kotlin Multiplatform project structure.</li></ul><p><strong>First, let’s complete the initial setup: create a Firebase account and link your Android and iOS apps.</strong></p><p>Go to the <a href="https://console.firebase.google.com/">Firebase console</a> and create a new project. Enter the project name, “click through” the remaining steps, and then we will need to add the iOS and Android apps.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-214H_m2B4Mpa0A5C7qYkQ.png" /></figure><p>For the Android app, we need package name. If the project was created using the Wizard, this is the value entered in the Project ID field</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/715/1*wpFpl5iULXW9VwyqV7jMWw.png" /></figure><p>otherwise, it can be found in the build.gradle.kts file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1012/1*3tLOmquvkD2qoB-aiIRdyg.png" /></figure><p>and enter the app name, next download google-services.json and move it to the folder <strong>composeApp</strong> of you project</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/326/1*XQ3WGQoJ4oYCHrxdxr0RfA.png" /></figure><p>Steps for adding dependencies will be covered later, now let’s set up the iOS part of our application. For iOS, you need to use the App Bundle ID, which is most easily found by opening the project in Xcode, iosApp directory</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/242/1*V-JoUWunXDb5Hi69JuA2Vw.png" /></figure><p>and go to Signing &amp; Capabilities -&gt; Targets (iosApp) and copy Bundle Identifier</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YV68nPj1xYBAhHKi5NRbGw.png" /></figure><p>Next, download the GoogleService-Info.plist file and add it to <strong>iosApp/iosApp</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/329/1*x7zJ5qxViP7Lt2aJ7dgFOw.png" /></figure><p><strong>And finally, we can start writing some code! :)</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*tMTHP3RG8Qwcqi1xbWsyKQ.gif" /></figure><p>Here is how the project structure looks</p><pre>Root Project (MyKMPApp)<br>├── composeApp/ # Main module containing the application code<br>│   ├── src/<br>│   │   ├── commonMain/ # All shared code (UI, Logic, ViewModels)<br>│   │   │   ├── kotlin/<br>│   │   │   │   └── org.example.project/<br>│   │   │   │       ├── App.kt # Entry point for Compose UI<br>│   │   │   └── composeResources/ # Shared resources (strings, images, fonts)<br>│   │   │<br>│   │   ├── androidMain/ # Android-specific code<br>│   │   │   ├── kotlin/<br>│   │   │   └── AndroidManifest.xml<br>│   │   │<br>│   │   └── iosMain/ # iOS-specific code (e.g., Platform.ios.kt)<br>│   │       └── kotlin/<br>│   │<br>│   └── build.gradle.kts # CMP module and dependency configuration<br>│<br>├── iosApp/ # Xcode project (Swift wrapper for iOS)<br>│   ├── iosApp/<br>│   │   ├── AppDelegate.swift<br>│   │   └── ContentView.swift # Calls Compose via ComposeUIViewController<br>│   └── iosApp.xcodeproj<br>│<br>├── gradle/ # Gradle configuration <br>|   ├── libs.versions.toml #libs.versions.toml<br>├── build.gradle.kts # Root build script<br>└── settings.gradle.kts # Module inclusion script</pre><p><strong>To set up our project’s dependencies for both Android and iOS, we will follow these steps (using CocoaPods for the iOS side):</strong></p><ul><li><strong>Update </strong>libs.versions.toml: Add the necessary versions and libraries to the version catalog.</li><li><strong>Integrate Google Services</strong>: Include the required plugins for cross-platform support.</li><li><strong>Add Firebase Dependencies</strong>: Configure the specific modules needed for Firebase functionality.</li></ul><pre>[versions]<br>firebase-bom = &quot;34.9.0&quot;<br>firebaseConfig = &quot;22.1.1&quot;<br>google-services-plugin = &quot;4.4.4&quot;<br>...........<br><br><br>[libraries]<br>android-firebase-bom = { module = &quot;com.google.firebase:firebase-bom&quot;, version.ref = &quot;firebase-bom&quot; }<br>firebase-config = { module = &quot;com.google.firebase:firebase-config&quot;, version.ref = &quot;firebaseConfig&quot; }<br>...........<br><br><br>[plugins]<br>googleServices = { id = &quot;com.google.gms.google-services&quot;, version.ref = &quot;google-services-plugin&quot; }<br>kotlinCocoapods = { id = &quot;org.jetbrains.kotlin.native.cocoapods&quot;, version.ref = &quot;kotlin&quot; }<br>...........</pre><p>Version of <strong>kotlinCocoapods</strong> must match the <strong>Kotlin</strong> version. Next, in the composeApp/build.gradle.kts file, we need to:</p><ul><li><strong>Add the </strong>kotlin<strong> scope</strong>: Ensure the configuration is placed within the Kotlin Multiplatform block.</li><li><strong>Enable the plugin</strong>: Connect the kotlinCocoapods plugin to the project.</li></ul><pre>plugins {<br>    ........<br>    alias(libs.plugins.googleServices)<br>    alias(libs.plugins.kotlinCocoapods)<br>}<br>........<br>kotlin {<br>........<br>  cocoapods {<br>        summary = &quot;Firebase remote config example&quot;<br>        version = &quot;1.0&quot;<br>        homepage = &quot;&quot;<br>        ios.deploymentTarget = &quot;16.0&quot;<br>        <br>        framework {<br>            baseName = &quot;ComposeApp&quot;<br>            isStatic = true<br>        }<br>        pod(&quot;FirebaseCore&quot;) {<br>            version = &quot;~&gt; 11.15&quot;  <br>            extraOpts += listOf(&quot;-compiler-option&quot;, &quot;-fmodules&quot;)<br>        }<br><br>        pod(&quot;FirebaseRemoteConfig&quot;) {<br>            version = &quot;~&gt; 11.15&quot;  <br>            extraOpts += listOf(&quot;-compiler-option&quot;, &quot;-fmodules&quot;)<br>        }<br>    }<br>  sourceSets {<br>    androidMain.dependencies {<br>      implementation(project.dependencies.platform(libs.android.firebase.bom))<br>      implementation(libs.firebase.config)<br>    }<br>  }<br>........<br>}<br></pre><p>Also necessary to add the following to the project level build.gradle.kts file:</p><pre>alias(libs.plugins.googleServices) apply false<br>alias(libs.plugins.kotlinCocoapods) apply false</pre><p>To ensure CocoaPods works correctly, you must remove the pre-generated “Compile Kotlin Framework” script. This script is incompatible with the CocoaPods setup in KMP. If you skip this step, you will encounter the fatal error: “<em>embedAndSign task cannot be used in a project with dependencies to pods.”</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aXi_6BZHHbCiGtVmUZUInA.png" /></figure><p>At this stage, your build.gradle.kts might look like a Christmas tree of red errors right now, but don’t worry — we’re about to fix that :) <br>Sync your project and execute these commands to link the iOS dependencies using CocoaPods. This part can be tricky, so here is a sequence of commands I found that works:</p><pre>rm -rf iosApp/Pods  <br>rm -rf iosApp/Podfile.lock<br>rm -rf ~/.cocoapods/repos<br>pod repo update<br>./gradlew podInstall<br><br>cd/iosApp/<br><br>pod install --repo-update</pre><p>When you run ./gradlew podInstall, you will see this notification.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/402/1*bodYAjNTYk-DqKYws7Pf5Q.png" /></figure><p>This happens because CocoaPods doesn’t modify the .xcodeproj file directly instead, it creates a separate workspace that wraps your project and includes all its dependencies. Without this workspace, Xcode won&#39;t recognize the Kotlin framework or any external pods, causing the iOS build to fail. The KMP plugin in Android Studio automatically detects that you&#39;re using CocoaPods, spots the .xcworkspace file, and suggests switching to it. This ensures that Android Studio correctly identifies all dependencies and builds the project successfully.</p><ul><li><strong>rm -rf iosApp/Pods</strong> → removes all installed pods (libraries).</li><li><strong>rm -rf iosApp/Podfile.lock</strong> → deletes the file with fixed pod versions.</li><li><strong>rm -rf ~/.cocoapods/repos</strong> → clears the entire CocoaPods repository cache (last resort).</li><li><strong>pod repo update</strong> → updates the local cache of all pods from the internet.</li><li><strong>./gradlew podInstall</strong> → the main command: generates the Podfile and installs the pods.</li><li><strong>cd iosApp &amp;&amp; pod install --repo-update</strong> → manually triggers a pod install with a repo update for troubleshooting.</li></ul><p>In the terminal, you should see something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3VjsSCCiWOVqEsLT-iYdug.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yC-V59kSo5xlpflc28WEjA.png" /></figure><p>After this, you should see a new Pods folder inside iosApp containing all the installed dependencies.</p><p>For iOS, we also need to add an initializer because, unlike Android, Firebase does not auto-initialize on iOS. To follow best practices, we will hook into didFinishLaunchingWithOptions to initialize Firebase. To do this, create a file named FirebaseInitializer in the composeApp/iosMain directory.</p><pre>@OptIn(ExperimentalForeignApi::class)<br>fun onDidFinishLaunchingWithOptions() {<br>    FIRApp.configure() // Call Firebase configure<br>}</pre><p>Next, in the iosApp/iosApp folder, create an AppDelegate.swift file. In this file, we will call the onDidFinishLaunchingWithOptions method that we created earlier</p><pre>import Foundation<br>import UIKit<br>import ComposeApp<br><br>class AppDelegate: NSObject, UIApplicationDelegate {<br><br>    func application(_ application: UIApplication,<br>                     didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -&gt; Bool {<br><br>        KMPInitializerKt.onDidFinishLaunchingWithOptions()<br><br>        return true<br>    }<br>}</pre><p>update iosApp/iosApp/iOSApp.swift to include the app delegate adapter:</p><pre>@main<br>struct iOSApp: App {<br>    // add this line<br>    @UIApplicationDelegateAdaptor(AppDelegate.self) var delegate <br>    var body: some Scene {<br>        WindowGroup {<br>            ContentView()<br>        }<br>    }<br>}</pre><p>Next, we’ll define an expect interface for our FirebaseRemoteConfigSource. This allows us to handle the platform-specific logic for Android and iOS in their respective modules. Start by creating the FirebaseRemoteConfigSource file in the commonMain directory.</p><pre>interface FirebaseRemoteConfigSource {<br>    fun getString(key: String): String<br>    fun getBoolean(key: String): Boolean<br>    fun getInt(key: String): Int<br>    suspend fun fetchAndActivate(): Boolean<br>}<br><br>expect suspend fun getFirebaseRemoteConfigReader(): FirebaseRemoteConfigSource</pre><p>Now, we need to implement the actual functions for each platform. The easiest way to do this is by using the IDE’s built in shortcuts: place your cursor on the expect suspend fun getFirebaseRemoteConfigReader() declaration, press option + enter (or alt + enter) and choose &quot;<strong>Create missing actuals</strong>&quot; for <strong>androidMain</strong> and <strong>iosMain</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/350/1*jh5SPGj_hGTfGVLJIvneyw.png" /></figure><p>This will generate the following files:</p><p><strong>iOS:</strong> FirebaseRemoteConfigReader.ios.kt in iosMain<br><strong>Android:</strong> FirebaseRemoteConfigReader.android.kt in androidMain</p><p>Android FirebaseRemoteConfigReader.android.kt</p><pre>import com.google.firebase.remoteconfig.FirebaseRemoteConfig<br>import com.google.firebase.remoteconfig.remoteConfigSettings<br>import kotlinx.coroutines.suspendCancellableCoroutine<br>import kotlinx.coroutines.tasks.await<br>import kotlin.coroutines.resume<br><br>actual suspend fun getFirebaseRemoteConfigReader(): FirebaseRemoteConfigSource {<br>    //We retrieve a singleton instance of Remote Config from the Firebase SDK.<br>    val config = FirebaseRemoteConfig.getInstance()<br><br>    /*<br>    Next, we define the Remote Config settings. <br>    By setting minimumFetchIntervalInSeconds to 0, <br>    we can pull fresh data with every request. <br>    but in real projects it is better to use a value like 3600 (1 hour)<br>    to optimize performance and avoid hitting rate limits.<br>    */<br>    val settings = remoteConfigSettings {<br>        minimumFetchIntervalInSeconds = 0 <br>    }<br><br>    //.await() — a suspend function that asynchronously waits for the settings to take effect, ensuring safe execution within coroutines.<br>    config.setConfigSettingsAsync(settings).await() <br><br>    return AndroidFirebaseRemoteConfigSource(config)<br>}<br><br>private class AndroidFirebaseRemoteConfigSource(<br>    private val config: FirebaseRemoteConfig<br>) : FirebaseRemoteConfigSource {<br><br>    override fun getString(key: String): String = config.getString(key)<br><br>    override fun getBoolean(key: String): Boolean = config.getBoolean(key)<br><br>    override fun getInt(key: String): Int = config.getLong(key).toInt()<br><br>    override suspend fun fetchAndActivate(): Boolean = suspendCancellableCoroutine { cont -&gt;<br>        config.fetchAndActivate()<br>            .addOnSuccessListener { cont.resume(true) }<br>            .addOnFailureListener { cont.resume(false) }<br>    }<br>}</pre><p>IOS FirebaseRemoteConfigReader.ios.kt</p><pre>import cocoapods.FirebaseRemoteConfig.FIRRemoteConfig<br>import kotlinx.cinterop.ExperimentalForeignApi<br>import kotlinx.coroutines.suspendCancellableCoroutine<br>import kotlin.coroutines.resume<br><br>actual suspend fun getFirebaseRemoteConfigReader(): FirebaseRemoteConfigSource {<br>    /*<br>    FIRRemoteConfig is the native iOS class from the Firebase SDK. <br>    We use this specific class (rather than FirebaseRemoteConfig as seen on Android) because on iOS, <br>    Firebase operates through Objective-C/Swift APIs rather than a Kotlin wrapper. <br>    FIRRemoteConfig is the &quot;original&quot; native object.<br>    */<br>    val config = FIRRemoteConfig.remoteConfig()<br><br>    config.configSettings.minimumFetchInterval = 0.0<br><br>    return IosFirebaseRemoteConfigSource(config)<br>}<br><br>private class IosFirebaseRemoteConfigSource(<br>    private val config: FIRRemoteConfig<br>) : FirebaseRemoteConfigSource {<br><br>    override fun getString(key: String): String =<br>        config.configValueForKey(key).stringValue<br><br>    override fun getBoolean(key: String): Boolean =<br>        config.configValueForKey(key).boolValue<br><br>    override fun getInt(key: String): Int =<br>        config.configValueForKey(key).numberValue.intValue<br><br>    override suspend fun fetchAndActivate(): Boolean = suspendCancellableCoroutine { cont -&gt;<br>        config.fetchAndActivateWithCompletionHandler { status, error -&gt;<br>            val success = error == null<br>            cont.resume(success)<br>        }<br>    }<br>}</pre><p>That’s it! Now we are ready to use Firebase Remote Config in our CMP project. But before we can fetch any data, we need to actually provide some! :) Go to your Firebase Console, find the Remote Config section, and hit “Create configuration” to get started.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TKLQ5AoxKjTisdecEyvRZg.png" /></figure><p>Create a Remote Config parameter named test_string_config with a default value of &quot;some test data,&quot; and save your changes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Mr4RhTXEZPNcNIu2RwWqGw.png" /></figure><p>Don’t forget to hit <strong>Publish changes </strong>after saving. Right now, your configuration is just a draft, and it won’t be live until you officially deploy it in the Firebase Console.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o4xwHrA_Y_Tr64LQ7-fKIw.png" /></figure><p>Now we are ready to fetch the data from Remote Config in our project. To do this, we’ll create a simple ViewModel and a screen to display the results. Since this article focuses specifically on Remote Config, <strong>please note that the code below is for demonstration purposes and shouldn’t be used in real projects :)</strong></p><pre>class HomeViewModel(): ViewModel() {<br><br>    private val _stringRemoteConfig = mutableStateOf(&quot;empty&quot;)<br>    val stringRemoteConfig: State&lt;String&gt; = _stringRemoteConfig<br><br>    init {<br>        loadRemoteConfig()<br>    }<br><br>    private fun loadRemoteConfig() {<br>        viewModelScope.launch {<br>            val configReader = getFirebaseRemoteConfigReader()<br><br>            val success = configReader.fetchAndActivate()<br><br>            val stringConfig = configReader.getString(&quot;test_string_config&quot;)<br>            _stringRemoteConfig.value = stringConfig<br>        }<br>    }<br><br>}</pre><pre>@Composable<br>fun HomeScreen(<br>    viewModel: HomeViewModel = koinViewModel()<br>) {<br>    val stringConfig by viewModel.stringRemoteConfig<br>    HomeScreenContent(stringConfig)<br>}<br><br>@Composable<br>private fun HomeScreenContent(stringConfig: String) {<br>    Column(<br>        modifier = Modifier<br>            .fillMaxSize()<br>            .background(Color.LightGray)<br>            .statusBarsPadding(),<br>        horizontalAlignment = Alignment.CenterHorizontally<br>    ) {<br>        Text(<br>            modifier = Modifier<br>                .padding(top = 40.dp),<br>            text = &quot;Firebase Remote Config:&quot;,<br>            fontSize = 24.sp<br>        )<br>        Text(<br>            modifier = Modifier.padding(top = 16.dp),<br>            text = &quot;stringConfig: $stringConfig&quot;,<br>            fontSize = 20.sp,<br>            color = if (stringConfig == &quot;empty&quot;) Color.Red else Color.DarkGray<br>        )<br>    }<br>}</pre><p>And that’s it! Launch the app, and you’ll see the Remote Config data live in your UI on both platforms. <strong>Congratulations, you did it!!!</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/918/1*11dsIqiCQFk0k2eZ1T1xvg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*vLZZMQrDXfKAbSO4U66xMQ.gif" /></figure><p>And we’re done! You can now use Remote Config in your KMP project. The best part? Since Firebase is already set up, adding features like Crashlytics or Authentication etc. will be easy peasy! If you have any suggestions or find any bugs, please let me know i’m always open to feedback. Also, feel free to connect with me on <a href="https://www.linkedin.com/in/vitalii-voitenko/">LinkedIn</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d75f79d257d4" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>