Simplified testing of iOS push notifications in the simulator with Xcode 11.4
Xcode 11.4 is here and it makes life easier for us developers. Apple's in-house
development environment gets another minor update, making testing push notifications
much easier (Release Notes Xcode 11.4).
Almost every iOS app developer comes into contact with the topic of push
notifications at some point. Often, testing push notifications involved a lot of
effort. This is changing with the new Xcode version and in this post we will show
you how to use the new feature.
From now on it is possible to test push notifications in the simulator via drag and drop.
Nothing has to be changed in the code itself. All that is needed is a valid APNs file
(.apns). This file must contain a valid Payload
The payload must be slightly customized to be tested on the simulator. On the top level
of the JSON payload the key: "Simulator Target Bundle" is needed. As value this gets the
bundle identifier of the app as string value.
The payload is now stored in an .apns file. If the corresponding app is installed on a
simulator and registered correctly for push notifications, the file can be dragged and
dropped into the simulator. The push notification will then be displayed in the
simulator. By modifying the file, all possible push notifications can be tested.
Furthermore it is possible to test the workflow of the app when a notification arrives,
without always having to send a real notification. This is a real relief for
If you want to automate the whole thing, you can also trigger the push notifications via the console.
In addition, the identifier of the simulator to which you want to send the push notification is required. The identifier can be
found in Xcode in the "Devices and Simulators" window.
A recommendation for anyone who works a lot with the simulator is Control Room,
a GitHub project by Paul Hudson. In the Mac application, a push notification can be sent
at the push of a button. But Control Room can do much more. Numerous settings can be
adjusted here (system, battery level, appearance). The application also allows you to
put a simulator in different states (position, internet connection) and thus test
applications in all conceivable situations.