InApp Messaging won't show message on custom event

拈花ヽ惹草 提交于 2019-12-22 14:50:19

问题


using

implementation 'com.google.firebase:firebase-analytics:17.2.1'
implementation 'com.google.firebase:firebase-inappmessaging-display:19.0.2'

I get the message when using the "Test on device" feature in Firebase I also get message when using the event "on_foreground" but I want to show a message not directly on app start, but when entering a new screen (when I send the event "Show_Category_Screen")

like this

FirebaseAnalytics mFirebaseAnalytics = FirebaseAnalytics.getInstance(activity);
mFirebaseAnalytics.logEvent("Show_Category_Screen", null);

And I set the InApp Message trigger event to "Show_Category_Screen". But nothing happens

The event successfully shows up in the DebugView in Firebase

I see this in the log

I/FIAM.Headless: Successfully fetched 2 messages from backend
I/FIAM.Headless: Removing display event listener
I/FIAM.Headless: Already impressed InAppCategoryMessage ? : false

I have the same problem in my iOS app. Is it possible to do this?


回答1:


I started playing with in app messaging today and this took some figuring out using the famous trial and error technique.

There are two ways for triggering events:

FirebaseAnalytics.getInstance(this).logEvent("main_screen_opened", null);

and

FirebaseInAppMessaging.getInstance().triggerEvent("main_screen_opened");

I've published a campaign with the trigger main_screen_opened, as you cannot do this while testing, test messages are show on app open:

Now, make sure you call triggerEvent() or logEvent() in the onResume() of the activity, it won't work if you do it on the OnCreate()!

@Override
protected void onResume() {
    super.onResume();

    FirebaseAnalytics.getInstance(this).logEvent("main_screen_opened", null);
    FirebaseInAppMessaging.getInstance().triggerEvent("main_screen_opened");
    ...
}

NOTE:* it will (probably?) not trigger the first time, to not bug the user right away. When you go to the home screen and go back into the app, it should show up now.

Edit: After some testing a bit more, it is ok if you put it in the onCreate(). When you check your logging, you'll see

Already impressed <your campaign name> ? : false

The second time you execute the logEvent() / Trigger(), the popup will show up



来源:https://stackoverflow.com/questions/58857581/inapp-messaging-wont-show-message-on-custom-event

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!