I am developing an iOS app in SwiftUI and using Firebase to send push notifications.
Now the push notification works fine in real device (my iPhone 11 with iOS 16.3.1). My iPhone can receive push notifications by sending test messages via Firebase console.
However, with the same code & configuration (without modifying anything), just change Xcode target from my iPhone to a simulator and run it, the simulator cannot receive any push notification by sending test messages via Firebase console.
From my log, the only difference I see is... the following function doesn't get called when testing on simulators (it is called when testing on my iPhone)
func application(_ application: UIApplication,
didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
print("APNs device token: \(deviceToken)")
Messaging.messaging().apnsToken = deviceToken
}
I've tried a few things like:
- make my iPhone and my Mac connect to the same Wifi
- delete a simulator and add it back
- try different iPhone simulators (iPhone 14, iPhone 11, etc.)
Noting resolves the issue. Could anyone shed some lights on this? XCode is 14.2