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.
Check out our book!
Integrating SwiftUI into UIKit Apps
Integrating SwiftUI intoUIKit Apps
UPDATED FOR iOS 17!
A detailed guide on gradually adopting SwiftUI in UIKit projects.
- Discover various ways to add SwiftUI views to existing UIKit projects
- Use Xcode previews when designing and building UI
- Update your UIKit apps with new features such as Swift Charts and Lock Screen widgets
- Migrate larger parts of your apps to SwiftUI while reusing views and controllers built in UIKit