firebase / firebase-ios-sdk

Firebase SDK for Apple App Development
https://firebase.google.com
Apache License 2.0
5.68k stars 1.49k forks source link

On Silent Notification, swizzling on, application:didReceiveRemoteNotification:userInfo: not being triggered #14016

Open bennyd-intenthq opened 2 weeks ago

bennyd-intenthq commented 2 weeks ago

Description

I sent a Silent Notification using firebase messaging api. Swizzling is on But the method application:didReceiveRemoteNotification:userInfo: not being triggered

Reproducing the issue

I sent a silent notification through https://fcm.googleapis.com/v1/projects/jedai-sdk/messages:send with the next body { "message": { "token": "FCM_TOKEN", "apns": { "headers": { "apns-priority": "5" // Use "5" for silent, background notifications }, "payload": { "aps": { "content-available": 1 } } }, "data": { "key1": "2", "key2": "value2" } } }

In my AppDelegate.swift I have the next implementation func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) { print("BennyDebug in didReceiveRemoteNotification \(userInfo)") completionHandler(.newData) }

When swizzling if off, the method being invoked. However when swizzling if on, this method not being called.

Firebase SDK Version

11.4.0

Xcode Version

16.1

Installation Method

Swift Package Manager

Firebase Product(s)

Messaging

Targeted Platforms

iOS

Relevant Log Output

No response

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

Expand Package.resolved snippet
```json { "originHash" : "2de48f62200869581144908dfcc89bccc4893821200c0c69381d679a4c257fef", "pins" : [ { "identity" : "aws-crt-swift", "kind" : "remoteSourceControl", "location" : "https://github.com/awslabs/aws-crt-swift", "state" : { "revision" : "326f95c24679984b81177d5d66ec1203489ded71", "version" : "0.15.0" } }, { "identity" : "aws-sdk-swift", "kind" : "remoteSourceControl", "location" : "https://github.com/awslabs/aws-sdk-swift.git", "state" : { "revision" : "5366bfc01bb25457f655ff480b72879dcb55fe11", "version" : "0.29.0" } }, { "identity" : "each", "kind" : "remoteSourceControl", "location" : "https://github.com/mark2b/Each", "state" : { "branch" : "master", "revision" : "367c777df0ae7d6cff70a46310d763fb7fcf95c2" } }, { "identity" : "fscalendar", "kind" : "remoteSourceControl", "location" : "https://github.com/WenchaoD/FSCalendar", "state" : { "revision" : "0fbdec5172fccb90f707472eeaea4ffe095278f6", "version" : "2.8.4" } }, { "identity" : "gzipfile.swift", "kind" : "remoteSourceControl", "location" : "https://github.com/mark2b/GZipFile.swift", "state" : { "branch" : "master", "revision" : "c9f7df3a1efb21959ff27a0340976f77a2d66ab5" } }, { "identity" : "l10n", "kind" : "remoteSourceControl", "location" : "https://github.com/mark2b/l10n", "state" : { "revision" : "962269dbfa37619279193f3e5a9266e3980e9e4a", "version" : "1.0.2" } }, { "identity" : "mgswipetablecell", "kind" : "remoteSourceControl", "location" : "https://github.com/MortimerGoro/MGSwipeTableCell.git", "state" : { "revision" : "2d02e9d228b4684eda87ea696cdb3dd77713e782", "version" : "1.6.14" } }, { "identity" : "nvactivityindicatorview", "kind" : "remoteSourceControl", "location" : "https://github.com/ninjaprox/NVActivityIndicatorView", "state" : { "revision" : "121455c4e630fcb95aaefd7e4257b0c2e3cfe6d5", "version" : "5.2.0" } }, { "identity" : "smithy-swift", "kind" : "remoteSourceControl", "location" : "https://github.com/smithy-lang/smithy-swift", "state" : { "revision" : "4d965ac32af105f48061b85eb36427b0c66be192", "version" : "0.33.0" } }, { "identity" : "swift-collections", "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-collections", "state" : { "revision" : "671108c96644956dddcd89dd59c203dcdb36cec7", "version" : "1.1.4" } }, { "identity" : "swift-log", "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-log.git", "state" : { "revision" : "9cb486020ebf03bfa5b5df985387a14a98744537", "version" : "1.6.1" } }, { "identity" : "tarscape", "kind" : "remoteSourceControl", "location" : "https://github.com/mark2b/Tarscape", "state" : { "branch" : "main", "revision" : "a9c01be87b3e7e63702de60d0c75e454d3e96da8" } }, { "identity" : "xmlcoder", "kind" : "remoteSourceControl", "location" : "https://github.com/MaxDesiatov/XMLCoder.git", "state" : { "revision" : "80b4a1646399b8e4e0ce80711653476a85bd5e37", "version" : "0.17.0" } } ], "version" : 3 } ```

If using CocoaPods, the project's Podfile.lock

Expand Podfile.lock snippet
```yml Replace this line with the contents of your Podfile.lock! ```
google-oss-bot commented 2 weeks ago

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

rizafran commented 2 weeks ago

Thanks for reporting, @bennyd-intenthq. Could you confirm if you've tapped the notification so the didReceiveRemoteNotification will be called?

bennyd-intenthq commented 2 weeks ago

Hi @rizafran . Upon (non-silent) notification

  1. The method didReceiveRemoteNotification is not called
  2. The method func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) { being called.
rizafran commented 2 weeks ago

Hi @bennyd-intenthq, I was able to reproduce the issue. The didReceiveRemoteNotification will only be called when I removed the UNUserNotificationCenter.current().delegate = self. I'll consult this to our engineers to see if it's a bug or intended.

rizafran commented 1 week ago

Internal tracking bug b/377924923.