Skip to content

Fix 2 notification bugs#3237

Open
julien4215 wants to merge 2 commits into
mainfrom
fix-notification
Open

Fix 2 notification bugs#3237
julien4215 wants to merge 2 commits into
mainfrom
fix-notification

Conversation

@julien4215
Copy link
Copy Markdown
Collaborator

  • Fix wrong channel id for challenge created notifications.

    The wrong channel id caused the notification to be parsed incorrectly when the user taps on it. Because of that, it would bring the user to the home screen instead of the challenge screen.

  • Only display the challenge received notifications from the socket if the app is in the foregroud because fcm already shows the notification when the app is in the background.

    Before this fix, when the app is in the background, it might show the notification from the socket (when the socket is still alive in the background) which is later overriden by the notification from fcm resulting in a confusing experience for the user.

The wrong channel id caused the notification to be parsed incorrectly
when the user taps on it. Because of that, it would bring the user to
the home screen instead of the challenge screen.
app is in the foregroud because fcm already shows the notification when
the app is in the background.

Before this fix, when the app is in the background, it might show the
notification from the socket (when the socket is still alive in the
background) which is later overriden by the notification from fcm
resulting in a confusing experience for the user.

// notifications from socket are only displayed if app is in foreground
final binding = TestWidgetsFlutterBinding.ensureInitialized();
binding.handleAppLifecycleStateChanged(AppLifecycleState.resumed);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is useful. More useful would be a test that assert that the notification is not shown in background.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests fail without it. I think it doesn't consider that the app is in foreground by default.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be very weird if the app wasn't in foreground by default during tests. The tests would not even work if that was the case.

I can't accept the PR until I have the real explanation for why the tests fail with the new code.

And also it needs a test that shows the notification is not shown in background.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants