Skip to content

Firebase Notification Swizzling Prevents Execution of didReceiveRemoteNotification Method #14660

Open
@tyler6204

Description

@tyler6204

Description

When Firebase notification method swizzling is enabled, the method application(_:didReceiveRemoteNotification:) does not execute. The expected behavior is for this method to be triggered upon receiving a remote notification while the app is in the background. However, it only triggers correctly if Firebase swizzling is explicitly disabled.

The method successfully executes when the Firebase notification swizzling is turned off, which suggests that Firebase's automatic method handling might be interfering with standard remote notification handling.

Reproducing the issue

Steps:

Enable Firebase notification swizzling (default behavior).

Implement application(_:didReceiveRemoteNotification:) to handle background notifications.

Send a remote notification with content-available payload.

Observe that the method does not execute.

Disable Firebase notification swizzling explicitly.

Send the remote notification again and confirm that the method executes as expected.

Minimal reproducible example:

@MainActor
func application(
    _ application: UIApplication,
    didReceiveRemoteNotification userInfo: [AnyHashable: Any]
) async -> UIBackgroundFetchResult {
    print("🔔 Received Background Notification")
    return .newData
}

Firebase SDK Version

10.9

Xcode Version

15.3

Installation Method

Swift Package Manager

Firebase Product(s)

Authentication, Messaging

Targeted Platforms

All

Relevant Log Output

If using Swift Package Manager, the project's Package.resolved

Expand Package.resolved snippet
{
  "originHash" : "9e805dd553b0e8652d0c79c3fd88edc2024f61f4826bf842d8b1e8c2556c4c2c",
  "pins" : [
    {
      "identity" : "abseil-cpp-binary",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/google/abseil-cpp-binary.git",
      "state" : {
        "revision" : "bbe8b69694d7873315fd3a4ad41efe043e1c07c5",
        "version" : "1.2024072200.0"
      }
    },
    {
      "identity" : "app-check",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/google/app-check.git",
      "state" : {
        "revision" : "61b85103a1aeed8218f17c794687781505fbbef5",
        "version" : "11.2.0"
      }
    },
    {
      "identity" : "engine",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/nathantannar4/Engine",
      "state" : {
        "revision" : "e9cf38a8a6e174f248b48a63b9b664315f67e347",
        "version" : "1.9.5"
      }
    },
    {
      "identity" : "facebook-ios-sdk",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/facebook/facebook-ios-sdk.git",
      "state" : {
        "revision" : "619d1772808425faa010d92293b26eeb9bc1d630",
        "version" : "17.4.0"
      }
    },
    {
      "identity" : "firebase-ios-sdk",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/firebase/firebase-ios-sdk",
      "state" : {
        "revision" : "d1f7c7e8eaa74d7e44467184dc5f592268247d33",
        "version" : "11.11.0"
      }
    },
    {
      "identity" : "generative-ai-swift",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/google-gemini/generative-ai-swift",
      "state" : {
        "revision" : "44b8ce120425f9cf53ca756f3434ca2c2696f8bd",
        "version" : "0.5.6"
      }
    },
    {
      "identity" : "googleappmeasurement",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/google/GoogleAppMeasurement.git",
      "state" : {
        "revision" : "dd89fc79a77183830742a16866d87e4e54785734",
        "version" : "11.11.0"
      }
    },
    {
      "identity" : "googledatatransport",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/google/GoogleDataTransport.git",
      "state" : {
        "revision" : "617af071af9aa1d6a091d59a202910ac482128f9",
        "version" : "10.1.0"
      }
    },
    {
      "identity" : "googleutilities",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/google/GoogleUtilities.git",
      "state" : {
        "revision" : "53156c7ec267db846e6b64c9f4c4e31ba4cf75eb",
        "version" : "8.0.2"
      }
    },
    {
      "identity" : "grpc-binary",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/google/grpc-binary.git",
      "state" : {
        "revision" : "cc0001a0cf963aa40501d9c2b181e7fc9fd8ec71",
        "version" : "1.69.0"
      }
    },
    {
      "identity" : "gtm-session-fetcher",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/google/gtm-session-fetcher.git",
      "state" : {
        "revision" : "a2ab612cb980066ee56d90d60d8462992c07f24b",
        "version" : "3.5.0"
      }
    },
    {
      "identity" : "interop-ios-for-google-sdks",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/google/interop-ios-for-google-sdks.git",
      "state" : {
        "revision" : "040d087ac2267d2ddd4cca36c757d1c6a05fdbfe",
        "version" : "101.0.0"
      }
    },
    {
      "identity" : "leveldb",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/firebase/leveldb.git",
      "state" : {
        "revision" : "a0bc79961d7be727d258d33d5a6b2f1023270ba1",
        "version" : "1.22.5"
      }
    },
    {
      "identity" : "nanopb",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/firebase/nanopb.git",
      "state" : {
        "revision" : "b7e1104502eca3a213b46303391ca4d3bc8ddec1",
        "version" : "2.30910.0"
      }
    },
    {
      "identity" : "promises",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/google/promises.git",
      "state" : {
        "revision" : "540318ecedd63d883069ae7f1ed811a2df00b6ac",
        "version" : "2.4.0"
      }
    },
    {
      "identity" : "purchases-ios",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/RevenueCat/purchases-ios.git",
      "state" : {
        "revision" : "c756269d79aa0f34e56d4a7f12f4dcc8c9381d47",
        "version" : "5.20.3"
      }
    },
    {
      "identity" : "sdwebimage",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/SDWebImage/SDWebImage.git",
      "state" : {
        "revision" : "cac9a55a3ae92478a2c95042dcc8d9695d2129ca",
        "version" : "5.21.0"
      }
    },
    {
      "identity" : "sdwebimageswiftui",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/SDWebImage/SDWebImageSwiftUI",
      "state" : {
        "revision" : "451c6dfd5ecec2cf626d1d9ca81c2d4a60355172",
        "version" : "3.1.3"
      }
    },
    {
      "identity" : "swift-protobuf",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/apple/swift-protobuf.git",
      "state" : {
        "revision" : "d72aed98f8253ec1aa9ea1141e28150f408cf17f",
        "version" : "1.29.0"
      }
    },
    {
      "identity" : "swift-syntax",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/swiftlang/swift-syntax",
      "state" : {
        "revision" : "0687f71944021d616d34d922343dcef086855920",
        "version" : "600.0.1"
      }
    },
    {
      "identity" : "swiftui-shimmer",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/markiv/SwiftUI-Shimmer",
      "state" : {
        "revision" : "0226e21f9bf355d40e07e5f5e1c33679d50e167f",
        "version" : "1.5.1"
      }
    },
    {
      "identity" : "transmission",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/nathantannar4/Transmission",
      "state" : {
        "revision" : "4c54a2880cbf5de8e826732ae04bbb89ff0e3bd4",
        "version" : "1.7.2"
      }
    },
    {
      "identity" : "turbocharger",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/nathantannar4/Turbocharger",
      "state" : {
        "revision" : "c504e85b01218f103936feddc0c60c61a1c20803",
        "version" : "1.3.3"
      }
    }
  ],
  "version" : 3
}

If using CocoaPods, the project's Podfile.lock

Expand Podfile.lock snippet
Replace this line with the contents of your Podfile.lock!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions