Firebase In App Messaging message not displaying
Asked Answered
A

1

7

I am integrating Firebase In-App Messaging feature in my application and when I am testing it on my device the message is not being displayed in the application.

I go from SplashActvity to MainActivity and the message is being displayed on both the screens but is dismissed as soon as the onDestroy method of SaplshActivity is called. The SplashActivity uses Handler for going to the MainActivity with 1500 milliseconds of duration. The message is auto-disappearing when onDestroy of SplashActivity is called.

Code for going to MainActivity

new Handler().postDelayed(new Runnable() {
        @Override
        public void run() {
            Intent intent = new Intent(SplashActivity.this, MainActivity.class);
            startActivity(intent);
            finish();
        }
    }, 1500);

Is there any way to directly open the message in MainActivity?

I've visited the following links for the search of this answer but I am not getting any help.

Link 1

Link 2

Any help will be appreciated. Thanks in advance.

Abortive answered 18/9, 2019 at 12:46 Comment(5)
I am dealing with the same problem on Android. What I have seen work on iOS is create a custom event via Firebase Analytics sdk with logEvent() and then use IAM sdk triggerEvent(). Example: analytics.logEvent("event_splash_screen_finished", bundle) and then FirebaseInAppMessaging.getInstance().triggerEvent("event_splash_screen_finished"); Your campaign should be configured to launch this in-app message whenever this event accours (under "Scheduling").. As I said it works on iOS but I have not been successful with it on Android. Custom events can't be used with the "Test on device" feature btwTravesty
So you are trying to say that test on device will always start from splash no matter what the trigger event we are trying to set?Abortive
What I am saying is A) It is a supported feature to trigger the in-app-message to surface by using your own custom event (after splash in your case) Your campaign in firebase console should be configured to trigger on that event. B) when using the "Test on your Device" you can not use custom events afaik - it will always be triggered early in Android's lifecycle. To test a campaign with custom events you have to publish it. This is all based on my experiance - i am still trying to accomplish simular things as you are. In my case it's a lock screen but not flash.Travesty
Alright, @Travesty thanks a ton...this information was quite helpful in my case. :)Abortive
always check to use latest version of inapp message implementationBarkeeper
A
24

please check if Firebase In-App Messaging API is disabled. Enable it by visiting

https://console.cloud.google.com/apis/library/firebaseinappmessaging.googleapis.com?project=(your project package )

Ashore answered 14/8, 2022 at 21:34 Comment(3)
Why is this not mentioned in the docs!Fechner
Absolutely insane 🤯. I was struggling to get it working but this is it, Another thing is that it only display once a day :(Purposeful
also, - click Credentials. - click keys that are marked as (auto-created by Firebase) - scroll, under API restrictions open the combo box, and make sure the Firebase Cloud Messaging Api is selected. -Click Save.Elenore

© 2022 - 2024 — McMap. All rights reserved.