urbanairship / airship-flutter

Flutter integration
Other
17 stars 16 forks source link

InboxMessageView is blank after opening it on iOS when app is not in background #140

Closed PetrasBartusis closed 1 year ago

PetrasBartusis commented 2 years ago

Preliminary Info

Opening an iOS message after getting a onShowInboxMessage (when opening a push notification) event from Airship.onShowInboxMessage and navigating to the message (using a MaterialPage to open a component that has InboxMessageView) does not load the message view.

What Airship dependencies are you using?

Airship 6.1.0 https://pub.dev/packages/airship_flutter (latest current version)

Report

What unexpected behavior are you seeing?

IMPORTANT: this only happens on iOS AND when the application is NOT running in the background. P.S. if the app is already opened or in the background, the InboxMessageView works fine.

This issue happens when the user opens the app from a push notification and Airship.onShowInboxMessage is triggered.

The example shows a blank page after navigation: image

After the initial opening, If I open the message again it works.

For now, I've solved the issue by using a FutureBuilder:

             FutureBuilder<String>(
                future: Future.delayed(1.seconds, () => ''),
                builder: (context, snapshot) => snapshot.hasData //
                    ? Expanded(child: InboxMessageView(messageId: _messageId))
                    : const HavenProgressIndicator(),
              )

This solves the issue since I think it might be a race condition of Flutter trying to show the message via InboxMessageView and Airship initializing on iOS.

What is the expected behavior?

The InboxMessageView should show the message center message if it is opened from a push notification and navigated to a component via InboxMessageView.

This works for Android, but not for IOS.

What are the steps to reproduce the unexpected behavior?

In order to replicate this:

  1. Use an iOS device;
  2. Have an InboxMessageView set up to show a message after Airship.onShowInboxMessage stream is updated with a messageId;
  3. Do not have the application in the background (in order to test you can use a --release mode)
  4. Send a push notification + message center message to the app;
  5. Open the push notification (it should open an InboxMessageView with a messageId)
oristanovic commented 2 years ago

Thanks for the report. We're looking into it.

oristanovic commented 2 years ago

@PetrasBartusis We identified the issue, the fix is in review at the moment.