You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, onNotificationTap is called whenever an intent with data is delivered to the activity and notificationTapWhichLaunchedAppFromTerminated returns data for all notification intents that launched the app, even the local ones.
This, for example, interferes with the flutter_local_notifications package, as local notifications are now triggering two callbacks.
However, in turn, Flutter Local Notifications checks for its own notifications and doesn't trigger when FCM/APNS notifications are tapped.
I could replicate the same behavior on both Android and iOS.
Android
One solution would be to specifically check for FCM Intent Actions in the following places:
Here:
However, as far as my research went, I found out that FCM either uses some hard-coded actions depending on the actual notification or ask the PackageManager for an intent, this was in our case ACTION_MAIN but could "theoretically" be any other valid action (lacking experience to answer this confidently).
Therefore, another, not so great, solution would be to just check for the keys used by popular Flutter Notification packages.
Collaborators are welcome to edit their research in, as my iOS experience is very limited.
TBD.
Workaround
My current workaround just checks for the payload key in the data (however, this only works as long as you always have a payload for local notifications!):
// "payload" means it's a local notification, handle elsewhere.if (data.containsKey("payload")) return;
The text was updated successfully, but these errors were encountered:
Currently,
onNotificationTap
is called whenever an intent with data is delivered to the activity andnotificationTapWhichLaunchedAppFromTerminated
returns data for all notification intents that launched the app, even the local ones.This, for example, interferes with the
flutter_local_notifications
package, as local notifications are now triggering two callbacks.However, in turn, Flutter Local Notifications checks for its own notifications and doesn't trigger when FCM/APNS notifications are tapped.
I could replicate the same behavior on both Android and iOS.
Android
One solution would be to specifically check for FCM Intent Actions in the following places:
Here:
push/push_android/android/src/main/kotlin/uk/orth/push/PushPlugin.kt
Lines 97 to 108 in 8de95ec
and here:
push/push_android/android/src/main/kotlin/uk/orth/push/PushPlugin.kt
Lines 61 to 75 in 8de95ec
However, as far as my research went, I found out that FCM either uses some hard-coded actions depending on the actual notification or ask the PackageManager for an intent, this was in our case
ACTION_MAIN
but could "theoretically" be any other valid action (lacking experience to answer this confidently).Therefore, another, not so great, solution would be to just check for the keys used by popular Flutter Notification packages.
Used Intent Actions:
MessageNotificationKeys.CLICK_ACTION
specified in the RemoteMessage. (Source)ACTION_VIEW
(android.intent.action.MAIN
)SELECT_NOTIFICATIONS
andSELECT_FOREGROUND_NOTIFICATIONS
iOS:
Collaborators are welcome to edit their research in, as my iOS experience is very limited.
TBD.
Workaround
My current workaround just checks for the
payload
key in the data (however, this only works as long as you always have a payload for local notifications!):The text was updated successfully, but these errors were encountered: