ahmetakil
ahmetakil

Reputation: 908

Flutter can't catch notification with terminated ios application

So my application requires that I store the notifications so the user can see them later on the screen.

Everything works fine on android whether the app is running, in the background, or terminated. For ios, I'm able to catch the notification whenever the app is running.

But the problem is whenever the app is terminated I can still send the ios notification and the device shows the notification but the data payload is not registered (It also works if the app is terminated but the user clicks on the notification and launches the app)

Here is the fcm configuration code show notification is just the local notifications plugin showing the notification and it saves the notification in shared preferences.

_fcm.configure(
      onBackgroundMessage: Platform.isIOS ? null : backgroundMessageHandler,
      onMessage: (Map<String, dynamic> message) async {
        logger.d("onMessage: $message");
        try {
          showNotifications(message);
        } catch (e) {
          print('PushNotificationService.initialise error: $e');
        }
      },
      onLaunch: (Map<String, dynamic> message) async {
        logger.d("onLaunch: $message");
        showNotifications(message);
      },
      onResume: (Map<String, dynamic> message) async {
        try {
          logger.d("onResume: $message");
          showNotifications(message);
        } catch (e) {
          print('PushNotificationService.initialise e: $e');
        }
      },
    );

So is there a way to catch and handle the data payload even if the ios app is terminated.

Upvotes: 1

Views: 840

Answers (1)

season
season

Reputation: 336

you need to add capability in the signing and capabilities section in Xcode for push notifications.

Upvotes: 0

Related Questions