Skip to content
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

iOS didNotificationLaunchAppreturn false and nullable payload when click on Notification in killed State #2531

Open
VictorJava opened this issue Feb 5, 2025 · 0 comments

Comments

@VictorJava
Copy link

VictorJava commented Feb 5, 2025

Describe the bug
didNotificationLaunchApp returns false, and the payload is empty if the app was in a terminated state and the user clicked on the DarwinNotificationAction.
Keep in mind that Android works as expected for similar steps. I encountered with issue only on iOS..

To Reproduce

  1. I receive Pushes using the library https://pub.dev/packages/firebase_messaging
  2. I added buttons to a category during app initialization. For example, the active_leak category has two buttons. Please take a look code below.
  3. Open the app at least once.
  4. Allow notifications for the app.
  5. Minimize the app and swipe it away (Terminate state – the app is not running in the background or in the list of active apps).
  6. Send a push notification via APNs, where the category matches the one from step 1: "category": "active_leak".
  7. Receive the push notification.
  8. Tap on one of the buttons.
  9. The app opens.
  10. getInitialMessage(https://pub.dev/packages/firebase_messaging) returns null and even final NotificationAppLaunchDetails? notificationAppLaunchDetails = await notificationsPlugin.getNotificationAppLaunchDetails().didNotificationLaunchApp returns false

Expected behavior
didNotificationLaunchApp should return true, and the payload should not be empty if the app was opened using DarwinNotificationAction. Isn't that correct?

That is how I add the ActionButtons using the flutter_local_notifications library

DarwinNotificationAction actionIgnoreLeak = DarwinNotificationAction.plain(
      NotificationButtonAction.ignoreLeak.value,
      ignoreStr,
      options: <DarwinNotificationActionOption>{
        DarwinNotificationActionOption.foreground,
      },
    );

    DarwinNotificationAction actionActiveLeak = DarwinNotificationAction.plain(
      NotificationButtonAction.activeLeak.value,
      detailsStr,
      options: <DarwinNotificationActionOption>{
        DarwinNotificationActionOption.foreground,
      },
    );

    DarwinNotificationCategory categoryIgnoreAndDetails =
        DarwinNotificationCategory(
            NotificationBuilder.darwinNotificationCategoryActiveLeak,
            actions: <DarwinNotificationAction>[
          actionIgnoreLeak,
          actionActiveLeak,
        ]);

    initializationSettingsDarwin = DarwinInitializationSettings(
      requestAlertPermission: false,
      requestBadgePermission: false,
      requestSoundPermission: false,
      notificationCategories: <DarwinNotificationCategory>[
        categoryIgnoreAndDetails
      ],
    );

I am using the Postman to sent Pushes on my device.
That is my JSON for Postman call. Feel free to check https://stackoverflow.com/a/62670409/21734721 how to grab Bearer token from Google for Postman.
Sample code to send push via the Postman

{
  "message": {
    "token": "eztm3jfE9UsgrphZUCSSMe:APA91bFj8qulosQh-_4mGlBk-96eWRQ62_kesdSQ0ICGVSKM9ylKVZWBtzhbN5esGMS5cJK3d4epzUDnq_q1CC8HKp3vCUi-faJLIlE7S_5eK4u8HxlDcCs",
    "notification": {
      "title": "some text",
      "body": "some text (optional)",
  },
    "data": {
      "style": "red_high_leak",
      "title": "some text (optional)",
      "message": "some text",
      "bodyAction": "active_leak",
      "contextDataType": "leak",
    },
    "apns": {
       "headers": {
         "apns-priority": "5",
       },
       "payload": {
         "aps": {
           "category": "active_leak",
           "content-available": 1,
           "mutable-content" : 1,
         }
       }
     },
  },
}
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

No branches or pull requests

1 participant