Skip to content

Conversation

@tikoua
Copy link

@tikoua tikoua commented Oct 11, 2025

Fixed an issue on the Android platform where clicking a notification after the app auto-started would not trigger the onDidReceiveNotificationResponse callback.
The original implementation only handled the onNewIntent scenario. However, when the app was auto-restarted in the background (e.g., by JobScheduler or other mechanisms), clicking a notification did not invoke the expected callback. To address this, additional logic was added in the onAttachedToActivity callback to parse and handle the specific notification action.

…notification after the app auto-started would not trigger the onDidReceiveNotificationResponse callback.
- 修正了传递给 processForegroundNotificationAction 的 intent 参数- 确保在处理前台通知操作时使用正确的 mainActivityIntent
- 避免因错误的 intent传递导致的通知响应处理异常
@Adelmostafa31
Copy link

the intent in line 1430 not exist.

@tikoua
Copy link
Author

tikoua commented Nov 5, 2025

the intent in line 1430 not exist.

You’re right — the intent at line 1430 doesn’t exist.
I’ve fixed it in a follow-up commit 83b71eb.

@MaikuB
Copy link
Owner

MaikuB commented Nov 15, 2025

Can you provide instructions on how to reproduce the issue that is supposed to be fix by this PR? Would this require certain phones to also reproduce the issue?

@MaikuB MaikuB added the question Further information is requested label Nov 15, 2025
@tikoua
Copy link
Author

tikoua commented Nov 15, 2025

Can you provide instructions on how to reproduce the issue that is supposed to be fix by this PR? Would this require certain phones to also reproduce the issue?

This issue is not device-specific, and most Flutter apps will never encounter it. However, in my case, I’m developing an instant-messaging app, and on Android we use a daemon process to revive the main process. This means the Dart runtime and Flutter engine may be started in the background. If a notification arrives during that time and the user taps it, the issue is triggered.
In short: after the app auto-starts in the background, but before the user manually opens the app, tapping a notification will reproduce the problem.

@MaikuB
Copy link
Owner

MaikuB commented Nov 26, 2025

Thanks for the explanation do you have more detailed guidance on how I could reproduce this? If possible an minimal app that can reproduce this would be great. Asking not because I don't believe you but so I can test and see if there's other ramifications of this change. From what I could see, it looks like there could also be a timing issue that this PR may in theory cause the callback to be fired on app launch from a notification from a cold start. To prevent this from happening, I believe this PR would need to be revisited. In my mind, it now sounds like best approach is to avoid a method to add the extra info into the intent and just do it whenever an intent is processed that a callback is fired. This presumably would help track if a notification has already been processed that it would avoid the timing issue

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

Labels

question Further information is requested

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants