使用以下方法在不同的活动中“开始”和“停止”InAppMessaging。
public static void inAppMessagingInitialization(Context context, boolean setSuppressed,String eventName){ //setSuppressed false means start getting message
FirebaseInAppMessaging.getInstance().setMessagesSuppressed(setSuppressed); //true==Stop inAppMessaging
if (!eventName.equals("")){
FirebaseAnalytics.getInstance(context).logEvent(eventName,null); //To Show InAppMessage in MainActivity. Need to add this event name in Web console campaign
FirebaseInAppMessaging.getInstance().triggerEvent(eventName);
}
}
如果您不想在 SplashActivity 中显示,请调用上述方法,如下所示:
inAppMessagingInitialization(context,true,""); //Stops inAppMessaging
要在 MainActivity 中显示 InAppMessage 调用上述方法,如下所示,并在 InAppMessaging 控制台中设置事件名称。
inAppMessagingInitialization(context,false,"main_activity_inappmessaging"); //Starts inAppMessaging