Testing Push Notifications on iOS Simulator in 2022
One last take on iOS simulator notifications.
About two years ago, we revisited a 7-year-old post about testing push notifications on the iOS simulator.
By then, Xcode 11.4 had been recently released, bringing improved support for push notifications on the simulator. In short, you could leverage raw .apns
files and throw those into a running simulator.
xcrun simctl push <device_uuid> <bundle_identifier> ~/Downloads/notification.apns
Although this was a significant improvement, it wasn't free of downsides. The most noticeable was the lack of support for Notification Service Extensions. Being unable to test all the aspects of push notifications, you would still find yourself using a physical device most of the times.
Enter Xcode 14
The latest Xcode release brought several well-appreciated improvements. Among them is a sight for sore eyes — real support for push notifications on the iOS simulator! 🎉
This time, Apple took advantage of the synergy between hardware and software and made it possible. Simulators running in macOS 13 on Mac computers with Apple silicon or T2 processors can receive push notifications like a physical device.
One vital detail worth noticing is the supported APNS environments. You can only run debug builds targeting the APNS Sandbox environment. Attempting otherwise will fail to register or receive push notifications.
Requirements
You're probably wondering what you must do to make this work. The answer couldn't be any better.
Nothing!
You're good to go if you have the qualifying hardware running macOS 13. If you are not sure your Mac qualifies, you can find a list of Macs with the T2 processor here.
Wrapping up
You can ditch your physical device in favour of this Xcode feature for testing push notifications. No more manual .apns
files either!
If this feature sparked your interest, you can find more about it on the Xcode 14 release notes here.
As always, we hope you liked this article and if you have anything to add, we are available via our Support Channel.