-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[firebase_messaging]: getInitialMessage returns null when clicking on the ActionButton if the app is terminated. #17051
Comments
Hi @VictorJava, thanks for the detailed report. This is the intended behaviour of |
@SelaseKay Thank you for your response. Of course, I have read the documentation. How can I retrieve the payload when a button is pressed? The button has the parameter UNNotificationActionOptions.foreground. Could you please take a look https://developer.apple.com/documentation/usernotifications/unnotificationactionoptions/foreground This means that the system does not handle the button press itself but instead opens the application, even if it was previously terminated. It is expected that after this, I should receive the payload, isn't that right? After all, this is the standard iOS logic. Are you saying that the firebase_messaging package does not cover the full functionality of the iOS system? |
Hi @VictorJava, are you using silent push notifications and relying on |
@SelaseKay Thanks for your reply. No, for iOS, I use https://pub.dev/packages/flutter_local_notifications only to add a category with buttons during app initialization: "category": "active_leak". I didn`t find how I can add categories and actions with https://pub.dev/packages/firebase_messaging. Maybe, you know how to do it without flutter_local_notifications? Then, I send an FCM JSON payload that includes a notification and the category.
If the app is in a terminated state, iOS natively triggers the notification with the pre-defined category "category": "active_leak". The iOS system handles this automatically, without the app's involvement. As I understand, this is standard iOS functionality. Please refer to the official documentation: Declaring Your Actionable Notification Types. If you tap on the message body while the app is in a terminated state, getInitialMessage returns the data. Thanks for your help. |
Can someone help me figure out how to get the notification payload when opening the app (by clicking on the notification) if the notification was displayed while the app was terminated? |
Hi @VictorJava, could you please create a minimal repository that reproduces the issue and share the link here? |
@SelaseKay Thanks for your reply. To send push notifications to iOS, you will need my APNs key, Apple ID team, bundle ID, and access to the FCM project. For obvious reasons, I can’t share these details publicly. If I prepare the code without the APNs key, Apple ID team, bundle ID, and FCM project access, along with detailed steps on how to integrate it, would you just need to connect the code to FCM on your end? Would that be sufficient for you? |
@SelaseKay Just a gentle reminder. |
Hi @VictorJava, you can provide the sample without those sensitive details. |
@SelaseKay I managed to intercept notification button presses using native Swift, which sends callbacks to Flutter. Unfortunately, getInitialMessage still didn't work, even with version 15.2.2. I'll talk to my customers if they allocate some time for me, I'll create a dummy application for you.
|
Hey @VictorJava. We need more information to resolve this issue but there hasn't been an update in 7 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 days I will close it automatically. If you have more information that will help us get to the bottom of this, just add a comment! |
Is there an existing issue for this?
Are you aware of the differences between iOS and Android background message handling?
Do you have an active Apple Developer account?
Are you using a physical iOS device to test background messages?
Have you enabled "Remote Notifications" & "Background Mode" (Checking options for "Background Processing" & "Remote Notifications") in your app's Xcode project?
Have you created an APNs key in your Apple Developer account & uploaded this APNs key to your Firebase console?
Have you disabled method swizzling for Firebase in your app?
Are you sending messages to your app from the Firebase Admin SDK?
I am using the Postman to this.
That is my JSON for Postman call. Feel free to check https://stackoverflow.com/a/62670409/21734721 how to grab auth.
Have you requested permission from the user to receive notifications?
Have you used the 'Console' application on your macOS device to check if the iOS device's system is throttling your background messages?
Sorry, I can`t attach the logger to the console.
Additional context and comments
Steps to Reproduce:
await notificationsPlugin.getNotificationAppLaunchDetails().didNotificationLaunchApp returns false
I understand that iOS(or Firebase service) displays the notification, not flutter_local_notifications.
Keep in mind that getInitialMessage is not null when tapping on the notification body, but if the user taps on a button, getInitialMessage is null, and didNotificationLaunchApp is false. It works fine if notification is received when the app is in a background state, but not in termitated.
However, the app still opens, meaning the click action is registered.
*How can I retrieve the payload of the notification when the user taps a button?
That is how I add the ActionButtons using the flutter_local_notifications library
The text was updated successfully, but these errors were encountered: