InApp Messaging不会在自定义事件上显示消息 [英] InApp Messaging won't show message on custom event

查看:136
本文介绍了InApp Messaging不会在自定义事件上显示消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用

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

在Firebase中使用在设备上测试"功能时,我收到消息 使用事件"on_foreground"时也会收到消息,但我不想直接在应用启动时显示消息,而是在进入新屏幕时(当我发送事件"Show_Category_Screen"时)

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")

像这样

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

然后将InApp Message触发事件设置为"Show_Category_Screen".但是什么也没发生

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

该事件成功显示在Firebase的DebugView中

The event successfully shows up in the DebugView in Firebase

我在日志中看到了

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

我的iOS应用程序中存在相同的问题.可以这样做吗?

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

推荐答案

我今天开始在应用消息中使用,这使用了著名的试错法来弄清楚.

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);

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

我已使用触发器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:

现在,请确保在活动的onResume()中调用triggerEvent()logEvent(),如果您在OnCreate()上执行此操作,则将不起作用!

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.

经过更多测试后,将其放在onCreate()中就可以了.当您检查日志记录时,您会看到

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

第二次执行logEvent()/Trigger()时,将显示弹出窗口

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

这篇关于InApp Messaging不会在自定义事件上显示消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆