WWDC23 deal: 40% off our book "Integrating SwiftUI into UIKit apps"! Learn more ...WWDC23 deal:40% off "Integrating SwiftUI into UIKit apps" >>
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.

Integrating SwiftUI into UIKit Apps by Natalia Panferova book coverIntegrating SwiftUI into UIKit Apps by Natalia Panferova book cover
WWDC23 offer
Our book "Integrating SwiftUI into UIKit apps" is now 40% off!

Discover various ways to adopt SwiftUI in existing UIKit projects and take full advantage of the new iOS 16 frameworks and APIs such as Swift Charts.

The offer is active until the 19th of June.