Solvedflutterfire [firebase_messaging] iOS notification onResume, onLaunch callback not working

We Tried creating notification in our flutter application and found it to be working perfectly fine in Android devices. When it comes to iOS device we are getting the notifications when the app is in the background or when it is not open, but on clicking them we aren't taken to the respective screens which are because the callbacks aren't called. Kindly help to fix this issue.

Versions Used:
Flutter: 1.12.13+hotfix.8
firebase_messaging: 6.0.9
Minimum iOS version supported: 10.0

To Reproduce
Steps to reproduce the behavior:

  1. Created APNs Auth Key and Configured in Firebase

  2. Enabled Capabilities

    • Push Notifications
    • Background Mode (Background Fetch and Remote Notifications)
  3. Added below code in AppDelegate.m
    if (@available(iOS 10.0, *)) {
    [UNUserNotificationCenter currentNotificationCenter].delegate = (id) self;

  4. Added below code in main.dart for listening onResume and onLaunch callbacks

      onMessage: (Map<String, dynamic> message) async {
        print('on message $message');
      onResume: (Map<String, dynamic> message) async {
        print('on resume $message');
      onLaunch: (Map<String, dynamic> message) async {
        print("OnLaunch Message");
    _firebaseMessaging.getToken().then((token) {
      print("NOTIFY TOKEN ${token}");

Note: I could not find the solution in #935 #1757 #1677 #23293

30 Answers

✔️Accepted Answer

@AlexandreRoba @SandyAra same issue exists or your comment solution working fine on firebase_messaging: ^6.0.12 ?
tested working fine without that line

firebase_messaging docs are killing dev time :(

Other Answers:

Had a similar issue -- including a minimal repo that can be used to demonstrate the erroneous behavior.

Describe the bug
Background notifications on iOS do not trigger the onLaunch / onResume methods in my Flutter app. I also do not see a badge / notification in the iOS notification center. Instead, I receive an onMessage trigger when the app is reopened

To Reproduce
I created a minimal repo that exhibits this behavior

  1. Clone the repository here
  2. Run the app on the iOS simulator
  3. Note the Token: xxx value in the Debug Console
  4. Move the app to the background
  5. Trigger a notification using the following curl command:
DATA='{"notification": {"body": "this is a body","title": "this is a title"}, "priority": "high", "data": {"click_action": "FLUTTER_NOTIFICATION_CLICK", "id": "1", "status": "done"}, "to": "<TOKEN>"}'
curl -H "Content-Type:application/json" -X POST -d "$DATA" -H "Authorization: key=AAAALOSN_jE:APA91bEl5CscNyXpHRrz9F4lJJnFTlt9_FPwEOvI54Q6dr2eSuS00rryGiEXkABdhfMSHimkHrybSh7r3kfhVlciBpO3HYPa_kyT34eg-JE3bWsUg479OQK5ANzCTpJ-bvktN1AWw9j4"

Expected behavior
I expect a notification to appear in the iOS Notification Center, that when clicked will trigger the onResume method. Instead, no notification is presented.

Additional context
Output of flutter doctor -v:

[] Flutter (Channel stable, v1.12.13+hotfix.9, on Mac OS X 10.15.3 19D76, locale en-BH)
     Flutter version 1.12.13+hotfix.9 at /Users/rock/Downloads/flutter
     Framework revision f139b11009 (2 days ago), 2020-03-30 13:57:30 -0700
     Engine revision af51afceb8
     Dart version 2.7.2

[] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
     Android SDK at /Users/rock/Library/Android/sdk
     Android NDK location not configured (optional; useful for native profiling support)
     Platform android-29, build-tools 29.0.2
     Java binary at: /Applications/Android
     Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
     All Android licenses accepted.

[] Xcode - develop for iOS and macOS (Xcode 11.3)
     Xcode at /Applications/
     Xcode 11.3, Build version 11C29
     CocoaPods version 1.8.4

[] Android Studio (version 3.5)
     Android Studio at /Applications/Android
     Flutter plugin version 42.1.1
     Dart plugin version 191.8593
     Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)

[] VS Code (version 1.43.2)
     VS Code at /Applications/Visual Studio
     Flutter extension version 3.8.1

[] Connected device (1 available)
     iPhone 11  11E9FF08-2E40-4812-A0A4-DC3B1E3398CC  ios (simulator)

 No issues found!

Note: I could not find the solution in #935 #1757 #1677 or #2011

Facing same issue, getting notification if app is not open on screen.
I want to redirect user to specific screen on notification click, but i am getting 3 different cases for notification

1. If app is in foreground

I don't get notification.

2. If app is in background (Not terminated)

I get notification, but on notification click unable to redirect to specific screen.

3. If app is terminated

I get notification, and on notification click i am able to redirect to specific screen. (I want this to be happen in all above cases)

Here is more detail of my issue.


This one worked for me, now i am able to redirect user in any case.

as he suggests to remove above code from swift or objective C file and it should work.

if (@available(iOS 10.0, *)) {
  [UNUserNotificationCenter currentNotificationCenter].delegate = (id<UNUserNotificationCenterDelegate>) self;

has anyone worked out a fix?

@iapicca the fix doesn't work. Please share an update with everyone on this thread.

More Issues: