firebase / firebase-android-sdk

Firebase Android SDK
https://firebase.google.com
Apache License 2.0
2.27k stars 574 forks source link

FIAM will not be displayed in non-main processes #5595

Closed imaiya closed 9 months ago

imaiya commented 10 months ago

[READ] Step 1: Are you in the right place?

Issues filed here should be about bugs in the code in this repository. If you have a general question, need help debugging, or fall into some other category use one of these other channels:

[REQUIRED] Step 2: Describe your environment

[REQUIRED] Step 3: Describe the problem

I am using the latest firebase bom version, my application has multiple processes, I manually initialize firebase in the application.

I configure analytics events as FIMA triggers in the firebase background (my app already has a large number of analytics events), but then events triggered by non-main processes will never display FIMA. I analyzed the FIMA source code and found that it is related to the AnalyticsEventsManager class, where FiamAnalyticsConnectorListener #onMessageTriggered () will only be called by the analytics component in the main process. but at this time, my main process activity is in the background, not the main process activity. When triggerInAppMessage () is called, fiamDisplay == null, so the FIMA message cannot be displayed.

This issue has blocked my app development, my app is used by 200 million users, please help me, thank you

Steps to reproduce:

What happened? How can we make the problem occur? This could be a description, log/console output, etc.

Two activities are in different processes, using the analytics event as a trigger, only the activity of the main process can display fima

Relevant Code:

Because onMessageTriggered () will only be called in the main process

final class FiamAnalyticsConnectorListener implements AnalyticsConnectorListener {
  private FlowableEmitter<String> emitter;

  FiamAnalyticsConnectorListener(FlowableEmitter<String> emitter) {
    this.emitter = emitter;
  }

  @Override
  public void onMessageTriggered(int id, Bundle extras) {
    if (id == AnalyticsConstants.FIAM_ANALYTICS_CONNECTOR_LISTENER_EVENT_ID) {
      emitter.onNext(extras.getString("events"));
    }
  }
}
google-oss-bot commented 10 months ago

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

argzdev commented 10 months ago

Hey @imaiya, thanks for reaching out. Just for context, the FIAM will not display when the app is in the background, however the FIAM will be displayed once the user returns back to the app:

https://github.com/firebase/firebase-android-sdk/blob/16a90fa48dcdcc4fc91fb0d6bf469a56bab21f50/firebase-inappmessaging-display/src/main/java/com/google/firebase/inappmessaging/display/FirebaseInAppMessagingDisplay.java#L175-L179

I analyzed the FIMA source code and found that it is related to the AnalyticsEventsManager class, where FiamAnalyticsConnectorListener #onMessageTriggered () will only be called by the analytics component in the main process. but at this time, my main process activity is in the background, not the main process activity. When triggerInAppMessage () is called, fiamDisplay == null, so the FIMA message cannot be displayed.

I'm not sure if I understand correctly. However, from your explanation, it looks like it is working as intended. We won't show the FIAM unless the app is in the foreground. If there are triggered analytics commands from the background, the app will display the FIAM once the user returns back to the app foreground.

To further investigate this issue, could provide steps to reproduce this behavior and also a minimal reproducible example? Thanks!

google-oss-bot commented 10 months ago

Hey @imaiya. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

google-oss-bot commented 9 months ago

Since there haven't been any recent updates here, I am going to close this issue.

@imaiya if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.