androidfirebasekotlinfirebase-in-app-messaging

Firebase In-App Messaging showing in SplashActivity. How to show it in MainActivity?


I have enabled Firebase In-App messaging for my android app. When i am testing In-App Messaging it is showing in SplashActivity of the app.

Activity flows like: SplashActivity>LoginActivity>MainActivity

Note: SplashActivity just have runnable to get delay of 3 seconds. LoginActivity have some functions to check wheter shared preferences are not null.

I tried to add in onCreate() this below line of code: FirebaseInAppMessaging.getInstance().setMessagesSuppressed(true)

And FirebaseInAppMessaging.getInstance().setMessagesSuppressed(false) in onDestroy()

I want this messsage to show in MainActivity.


Solution

  • Firebase in-app messaging is triggered by analytical events.

    if you want show message in MainActivity ->

    class MainActivity : AppCompatActivity() { 
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        ...
        FirebaseAnalytics.getInstance(this).logEvent("main_activity_ready",null)
        //or 
        //FirebaseInAppMessaging.getInstance().triggerEvent("main_activity_ready");
    
    }
    }
    

    and select this event in firebase console.

    enter image description here