InAppMessage auto disappears once is shown
Asked Answered
C

1

3

Hi I've recently added InAppMessaging to my project which seems to be easy to integrate, but for me doesn't work as it's expected.

First of all I've added this to the build.gradle :

implementation 'com.google.firebase:firebase-core:17.0.1'
implementation 'com.google.firebase:firebase-inappmessaging-display:18.0.2'

then and because I don't want to show the message at the splash screen (IntroActivity.java) I'm doing :

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    binding = DataBindingUtil.setContentView(this, R.layout.activity_intro);
    binding.setActivity(this);

    //Disabling firebase in app messaging
    FirebaseInAppMessaging.getInstance().setMessagesSuppressed(true);
}

For the MainActivity.java I'm stopping the suppressing at the onStart :

@Override
protected void onStart() {
    super.onStart();
    FirebaseInAppMessaging.getInstance().setMessagesSuppressed(false);
}

The structure of the main activity is a FragmentLayout with a bottom navigation bar, that fragment layout has 4 different fragments, the first one (the one that is loaded at the beginning) has different recycler views showing information coming from the API (data loaded at the intro, using Apollo GraphQL for Android).

Finally I create the InAppMessage going to Firebase Console -> InAppMessaging -> New Campaign -> Card, setting al the basic info like title and image -> target -> select my app -> Scheduling -> no ending date and events : "app_launch" and "on_foreground" -> then next and publish.

When I restart the app, after the intro activity I can see the InAppMessage for a sec and then disappears, I wonder if it's related to the suppressing, or for some reason when the message is shown the recycler views of the main fragment are not shown and when they get created are disabling the msg?

Any clue or thought will be welcome. Thanks

Chifforobe answered 26/7, 2019 at 5:36 Comment(2)
hey man, did you get any luck with that? I'm having the same problem here. I don't want to show at the splash screen but want to show in home screen.Biaxial
Hi there, no... I was asked to disabled for now (because is in beta), Tested it in a simple project with just an activity and no fragments and works fine... so I wonder if the problem is how the UI is builtChifforobe
S
0

Put these two lines in the activity or fragment where you want to show

FirebaseAnalytics.getInstance(getContext()).logEvent("EVENT_NAME_YOU_WANT",null);
FirebaseInAppMessaging.getInstance().triggerEvent("EVENT_NAME_YOU_WANT");

And don't forget to call it in onResume() method. It solved my problem.

Shelburne answered 10/5, 2020 at 12:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.