skip to Main Content

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

2

Answers


  1. Chosen as BEST ANSWER

    For the Mac computer, you need one with Apple silicon or T2 processors:

    If your Mac's CPU starts with an M, you are good or you must have a Mac computer that has Apple T2 Security Chip:

    iMac (Retina 5K, 27-inch, 2020)
    iMac Pro
    Mac Pro (2019)
    Mac Pro (Rack, 2019)
    Mac mini (2018)
    MacBook Air (Retina, 13-inch, 2020)
    MacBook Air (Retina, 13-inch, 2019)
    MacBook Air (Retina, 13-inch, 2018)
    MacBook Pro (13-inch, 2020, Two Thunderbolt 3 ports)
    MacBook Pro (13-inch, 2020, Four Thunderbolt 3 ports)
    MacBook Pro (16-inch, 2019)
    MacBook Pro (13-inch, 2019, Two Thunderbolt 3 ports)
    MacBook Pro (15-inch, 2019)
    MacBook Pro (13-inch, 2019, Four Thunderbolt 3 ports)
    MacBook Pro (15-inch, 2018)
    MacBook Pro (13-inch, 2018, Four Thunderbolt 3 ports)
    

    And make sure your Firebase SDK is 10.3.0 or above. If you use older version, you will see a log saying

    Running InstanceID on a simulator doesn't have APNS. Use prod profile by default.

    when you assign APN to Firebase.

    With above two things, XCode simulators can receive remote push notifications successfully even with multiple instances.


  2. Make sure that you have at least Firebase 10.3. Before that, Firebase did not support push notifications on the simulator.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search