Testing push notifications On the simulator — iOS
From XCode 11.4 onwards we can test push notifications in the simulator as well. Before proceeding with this ensure that the project is set up and notification permissions are given. For reference:
There are two ways by which we can send push notifications:
- By simply dragging the APNS file on our simulator
- By using terminal
We will go through both one by one.
APNS file
Irrespective of how we are sending push notifications we need to create one file with .apns extension. For reference:
{
"Simulator Target Bundle": "com.budhiraja.NotificationTest",
"aps": {
"alert": {
"title": "Title",
"subtitle": "Subtitle",
"body": "Body",
}
}
}
Here, the Simulator Target Bundle refers to the Bundle Identifier of the app. aps defines the contents of the notification.
if you drag apns file to the simulator you should see the notification.
Although this works perfectly you might encounter a use case where you want to send push notifications through a script for testing purposes. In that case, we can do it via the terminal.
For this, we need to find the device ID for the simulator.

e.g. device ID for iPhone 14 Pro Max is A1374369–6BD5–4E2B-A1C2–103ED22E3F88.
xcrun simctl push deviceID bundleID file
We know that,
bundleID = com.budhiraja.NotificationTest file = ~/Desktop/notification.apns
xcrun simctl push A1374369-6BD5-4E2B-A1C2-103ED22E3F88 com.budhiraja.NotificationTest ~/Desktop/notification.apns
since we are passing the target bundle ID directly we can skip the Simulator Target Bundle from apns file in this case.
{
"aps": {
"alert": {
"title": "Push Notification",
"subtitle": "Test Push Notifications",
"body": "Testing Push Notifications on iOS Simulator",
}
}
}