NEW BOOK! Swift Gems: 100+ tips to take your Swift code to the next level. Learn more ...NEW BOOK! Swift Gems:100+ advanced Swift tips. Lear more...
Quick Tip Icon
Quick Tip

Testing remote push notifications on iOS simulator in Xcode 14

I recently discovered that starting from Xcode 14 we can test remote push notifications on an iOS simulator. Before this, simulators were unable to provide a device token, limiting us to locally simulating notifications using .apns payload files and the simctl push command.

To be able to send remote push notifications to an iOS simulator in Xcode 14, we have to be running macOS 13 on a computer with an Apple silicon or a T2 processor. In this setup, the simulator generates a unique registration token, which is specific to the combination of the simulator and the Mac hardware it’s running on.

The simulator supports the Apple Push Notification Service (APNS) Sandbox environment, which means that we have to connect to api.sandbox.push.apple.com to send a notification to the simulator.

I think this feature is great, since it lets us test the entire process of sending a push notification, when we don't have a real device at hand. It also allows us to use the simulator for testing more features, like Notification Service Extensions, that wasn't possible with .apns payload files or the simctl push command in the terminal.

Swift Gems by Natalia Panferova book coverSwift Gems by Natalia Panferova book cover

Check out our new book!

Swift Gems

100+ tips to take your Swift code to the next level

Swift Gems

100+ tips to take your Swift code to the next level

  • Advanced Swift techniques for experienced developers bypassing basic tutorials
  • Curated, actionable tips ready for immediate integration into any Swift project
  • Strategies to improve code quality, structure, and performance across all platforms
  • Practical Swift insights from years of development, applicable from iOS to server-side Swift