firebase-android-sdk: Message is not showing!

Hi, I have a similar problem issue 977 with two activities. Message is not showing on second activity after first has destroyed.

I suppose, there is a problem with calling FirebaseInAppMessaging.clearDisplayListener() in FirebaseInAppMessagingDisplay.onActivityDestroyed without checking which activity has destroyed (current or previous). As a result, the app can skip messages.

I use firebase-inappmessaging-display:19.0.2

Reproducible example here

Steps:

  1. Get example app’s Instance ID
  2. Close example app
  3. send test in-app message from firebase console
  4. open app (open FirstActivity)
  5. FirstActivity open SecondActivity
  6. FirstActivity has finished.
  7. SecondActivity still opened.
  8. The message was received but not showing.

Logcat report:

2019-12-24 13:01:07.241 17432-17432/com.master8.experimentalproject D/FIAM.Display: Created activity: com.master8.experimentalproject.FirstActivity
2019-12-24 13:01:07.292 17432-17432/com.master8.experimentalproject D/FIAM.Display: Started activity: com.master8.experimentalproject.FirstActivity
2019-12-24 13:01:07.292 17432-17432/com.master8.experimentalproject I/FIAM.Headless: Setting display event listener
2019-12-24 13:01:07.295 17432-17432/com.master8.experimentalproject I/FIAM.Headless: went foreground
2019-12-24 13:01:07.295 17432-17432/com.master8.experimentalproject D/FIAM.Headless: Event Triggered: ON_FOREGROUND
2019-12-24 13:01:07.295 17432-17432/com.master8.experimentalproject D/FIAM.Display: Resumed activity: com.master8.experimentalproject.FirstActivity
2019-12-24 13:01:07.297 17432-17533/com.master8.experimentalproject I/FIAM.Headless: Forcing fetch from service rather than cache. Test Device: true | App Fresh Install: true
2019-12-24 13:01:07.297 17432-17533/com.master8.experimentalproject I/FIAM.Headless: Recoverable exception while reading cache: /data/user/0/com.master8.experimentalproject/files/fiam_impressions_store_file (No such file or directory)
2019-12-24 13:01:07.300 17432-17533/com.master8.experimentalproject I/FIAM.Headless: Fetching campaigns from service.
2019-12-24 13:01:07.322 17432-17432/com.master8.experimentalproject I/FIAM.Headless: Removing display event listener
2019-12-24 13:01:07.322 17432-17432/com.master8.experimentalproject D/FIAM.Display: Pausing activity: com.master8.experimentalproject.FirstActivity
2019-12-24 13:01:07.352 17432-17432/com.master8.experimentalproject D/FIAM.Display: Created activity: com.master8.experimentalproject.SecondActivity
2019-12-24 13:01:07.389 17432-17432/com.master8.experimentalproject D/FIAM.Display: Started activity: com.master8.experimentalproject.SecondActivity
2019-12-24 13:01:07.389 17432-17432/com.master8.experimentalproject I/FIAM.Headless: Setting display event listener
2019-12-24 13:01:07.392 17432-17432/com.master8.experimentalproject D/FIAM.Display: Resumed activity: com.master8.experimentalproject.SecondActivity
2019-12-24 13:01:07.524 17432-17432/com.master8.experimentalproject D/FIAM.Display: Stopped activity: com.master8.experimentalproject.FirstActivity
2019-12-24 13:01:07.526 17432-17432/com.master8.experimentalproject I/FIAM.Headless: Removing display event listener
2019-12-24 13:01:07.526 17432-17432/com.master8.experimentalproject D/FIAM.Display: Destroyed activity: com.master8.experimentalproject.FirstActivity
2019-12-24 13:01:07.681 17432-17533/com.master8.experimentalproject I/FIAM.Headless: Successfully fetched 1 messages from backend
2019-12-24 13:01:07.682 17432-17533/com.master8.experimentalproject D/FIAM.Headless: Updating contextual triggers for the following analytics events: []
2019-12-24 13:01:07.690 17432-17533/com.master8.experimentalproject D/FIAM.Headless: Decoding message: # com.google.firebase.inappmessaging.MessagesProto$Content@533ba749
    banner {
      background_hex_color: "#3ca9ff"
      body {
        hex_color: "#ffffff"
        text: "\320\242\320\265\320\272\321\201\321\202 \321\201\320\276\320\276\320\261\321\211\320\265\320\275\320\270\321\217"
      }
      title {
        hex_color: "#ffffff"
        text: "\320\227\320\260\320\263\320\276\320\273\320\276\320\262\320\276\320\272"
      }
    }

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 3
  • Comments: 25 (7 by maintainers)

Most upvoted comments

Hey folks, we are aware of this and I am currently working on a solution. Yeah the issue is exactly as you folks describe, the way we hook into the activity lifecycle doesn’t work well for apps with splash screens. The problem is that not doing this has resulted in callbacks referencing dead activities and crashing apps. I am going to be prioritizing investigating this issue this week.

The real solution would be to either:

  1. re-display messages that have not been acknowledged/manually closed by the user
  2. allow developers to mark activities as “unusable” and trigger messages in the next activity, common use-case would be a login or splash activity. https://firebase.google.com/docs/in-app-messaging/modify-message-behavior?platform=android#temporarily_disable_in-app_messages cannot be used for that, as it will not trigger events at a later stage, right?
  3. let the inappmessage dialog be their own activity, then it should not matter anyway

Sorry for the delay here. Our engineering team said that this is basically WAI (working as intended), what we used to do in this case was completely crash the app, because now the FIAM UI references an activity that doesn’t exist anymore. I think the solution here would be to somehow set the new activity to be the “parent” of the UI.

Hello @aguatno , sorry for a noob question, but where can I find status of the bug#147662257, please?