In the past, testing push notifications on iOS simulators was quite challenging due to certain limitations. Prior to Xcode 14, receiving push notifications in a simulator was not possible and developers had to rely on local simulations using .apns payload files and the simctl push command. We have already seen how to simulate push notifications in a simulator in the article, Simulating remote push notifications in a simulator

However, Xcode 14 allows iOS simulators running on macOS 13 on Macs with Apple silicon or T2 processors to receive remote push notifications just like a physical device.

Sending Remote Push Notifications to an iOS Simulator

In truth, the process is quite straightforward. If your Mac is equipped with an Apple Silicon or T2 Processor, you’re all set. Just send your remote push notifications in sandbox mode as you typically would, and, they’ll pop up in the simulator.


Sending Remote Push Notifications to an iOS Simulator


Let me explain how it works behind the scenes.
With Xcode 14, the simulator generates unique registration token for each combination of simulator and Mac hardware.
This lets us test the entire process of sending a push notification, which was not previously possible.
It’s worth noting that only debug builds targeting the Apple Push Notification Service (APNS) Sandbox environment are supported.
This means that we have to connect to api.sandbox.push.apple.com to send remote push notifications to the simulator, which you might have been doing already.

Wrapping Up

If you’re dabbling in iOS development, you’d surely find this feature worth your while. Were you aware of this already? Share your insights in the comments below.

References

About the author