OneSignal / OneSignal-Flutter-SDK

OneSignal is a free push notification service for mobile apps. This plugin makes it easy to integrate your flutter app with OneSignal
https://www.onesignal.com
Other
616 stars 213 forks source link

[Bug]: LaunchUrl click behavior is inconsistent between Android and iOS with GoRouter #911

Open zvikarp opened 3 months ago

zvikarp commented 3 months ago

What happened?

When clicking on a notification, if the app is using GoRouter (it handles deep links out of the box), on Android the app redirects to the launch URL, as if the user clicked on a deep link. But on iOS the launch Url is not provided to the app navigator and we need to use OneSignal.Notifications.addClickListener to detect the clicks on the notification. This is the case if the app is in the foreground, background, or terminated.

Steps to reproduce?

1. Create a flutter app.
2. Add GoRouter.
3. Add a Redirect to GoRouter that just prints the url.
3. Initialize OneSignal etc.
4. Send a notification with a LaunchUrl to the app, the URL could be anything, a valid URL or not.
5. Run on Android and iOS and see the prints only in Android.
6. Add `OneSignal.Notifications.addClickListener`.
7. Send notifications again and see it trigger on Both Platforms.
8. Test and see the same results when the app is in the foreground, background or terminated.

What did you expect to happen?

OneSignal notifications launchUrl should be consistent across platforms, either open the URL as if it is a deep link or don't. And if it is not, that should be properly documented.

OneSignal Flutter SDK version

onesignal_flutter: ^5.2.0

Which platform(s) are affected?

Relevant log output

No response

Code of Conduct