How to Test Push Notifications on iOS Simulator
In this article
You can test push notifications on the iOS Simulator by adding a properly formatted APNs payload file to your project and dragging it onto the booted simulator, or by using the xcrun simctl push command. The Simulator does not receive real remote notifications from Apple's push service, so you must simulate them locally. This guide walks through the exact steps using Xcode's built-in tools, plus how to handle common failures.
What You'll Need
- A Mac with Xcode installed (the Simulator is part of Xcode).
- An iOS Simulator running a recent iOS version (iOS 16 or later recommended for the drag-and-drop method).
- Your app installed and running in the Simulator, with notification permission granted.
- A sample APNs payload file (JSON) that matches your app's notification structure.
- Optional: Terminal access for the
xcrun simctlcommand-line method.
Step-by-Step
- Launch your app in the Simulator and grant notification permission. Open your app, and when prompted for notifications, tap Allow. If you previously denied permission, go to the Simulator's Settings app > Notifications > your app and enable Allow Notifications. Without permission, simulated pushes will not appear.
- Create a payload file. In your project or anywhere on your Mac, create a new plain text file and name it something like
payload.json. Paste a valid APNs payload. A minimal example for an alert notification:
Replace{ "Simulator Target Bundle": "com.yourcompany.yourapp", "aps": { "alert": { "title": "Test Notification", "body": "This is a test push from the simulator." }, "sound": "default", "badge": 1 } }com.yourcompany.yourappwith your app's actual bundle identifier. TheSimulator Target Bundlekey tells the Simulator which app should receive the notification. You can also include custom data keys outside theapsdictionary for your app to read. - Drag the payload file onto the Simulator. With the Simulator window active and your app in the foreground or background, drag the
payload.jsonfile from Finder and drop it anywhere on the Simulator screen. The notification should appear as a banner or in Notification Center within a second or two. This method works on iOS 16 and later; on older simulator versions, use the command-line method below. - Alternatively, use the
xcrun simctl pushcommand. Open Terminal and run:
Thexcrun simctl push booted com.yourcompany.yourapp payload.jsonbootedkeyword targets the currently running simulator. You can also specify a device UDID instead ofbooted. This command works even if the Simulator is not the active window and is useful for scripting or repeated tests. - Verify the notification appears. If your app is in the foreground, iOS may not show a banner by default; you need to implement
UNUserNotificationCenterDelegatemethods to display it. For testing, background the app (press Cmd+Shift+H to go to the Home screen) and then send the push. The notification should appear as a banner or in Notification Center. - Test notification actions and custom data. To test action buttons, include a
categoryin your payload and register the category in your app. To test custom data, add keys outsideapsand read them in your notification handling code. You can also simulate a silent push by omitting thealertdictionary and settingcontent-availableto 1, but note that silent pushes may be throttled by the system and are not guaranteed to wake the app in the Simulator. - Reset notification permissions if needed. If notifications stop appearing, go to the Simulator's Settings > General > Transfer or Reset iPhone > Reset > Reset Location & Privacy. This resets all privacy permissions, including notifications, so your app will prompt again on next launch. Be aware this also resets other privacy settings.
Common Mistakes
- Forgetting the bundle identifier. The
Simulator Target Bundlekey must match your app's bundle ID exactly, including case. A mismatch means the notification is silently ignored. - Using a payload without the
apsdictionary. Theapskey is required for the system to recognize the payload as a notification. Without it, nothing happens. - Not granting notification permission. If the user denied permission, simulated pushes will not display. Check Settings > Notifications.
- Expecting real remote pushes to work. The Simulator cannot receive pushes from APNs. You must simulate them locally.
- Dragging the file onto the wrong window. Drop the file directly onto the Simulator screen, not onto Xcode or another app.
- Using an outdated simulator version. Drag-and-drop payload support was added in iOS 16. On older versions, use
simctl push.
Tips
- Keep a set of payload files for different scenarios (alert, silent, with actions) to speed up testing.
- Use the
--helpflag withxcrun simctl pushto see additional options like specifying a device by UDID. - Test with the app in both foreground and background to ensure your delegate methods handle each case correctly.
- If you need to test rich notifications with images, include a
mutable-contentflag and a notification service extension in your app. - Remember that the Simulator does not support all push features, such as communication notifications or time-sensitive interruptions, so verify those on a real device.
Troubleshooting
If the notification does not appear, work through these checks in order:
- Confirm the Simulator is booted and your app is installed. Run
xcrun simctl list devicesto see booted devices. If your app is not installed, install it via Xcode. - Check the payload syntax. Use a JSON validator to ensure there are no trailing commas or missing quotes. A malformed payload will be rejected.
- Verify the bundle identifier. Double-check that
Simulator Target Bundlematches your app's bundle ID exactly. You can find it in Xcode under your target's General tab. - Ensure notification permission is granted. Go to the Simulator's Settings > Notifications > your app and confirm Allow Notifications is on.
- Try the command-line method. If drag-and-drop fails, use
xcrun simctl pushwith the same payload. If that works, the issue may be with the drag-and-drop interaction. - Restart the Simulator. Quit Simulator (Cmd+Q) and relaunch it from Xcode's Xcode > Open Developer Tool > Simulator. Then reinstall your app if needed.
- Reset privacy settings. As a last resort, reset location and privacy in the Simulator's Settings, then relaunch your app and grant permission again. This will erase all privacy permissions, so you'll need to re-grant any others your app uses.
Frequently Asked Questions
Can I receive real push notifications from APNs in the iOS Simulator?
No. The Simulator does not connect to Apple's Push Notification service. You must simulate notifications using a payload file or the simctl push command.
Why does my notification not show a banner when the app is in the foreground?
By default, iOS does not display banners for notifications while the app is in the foreground. You need to implement UNUserNotificationCenterDelegate and return .banner (or the appropriate presentation option) in userNotificationCenter(_:willPresent:withCompletionHandler:).
Does the drag-and-drop method work on all simulator versions?
Drag-and-drop payload support was introduced in iOS 16. For earlier versions, use the xcrun simctl push command-line tool.
Can I test silent notifications in the Simulator?
You can send a payload with content-available: 1 and no alert, but the system may throttle silent pushes, and delivery is not guaranteed. Use a real device for reliable silent push testing.
How do I test notification actions like buttons?
Include a category key in your payload that matches a category you registered with UNNotificationCategory. Then long-press or pull down the notification to reveal the actions.
Is there a limit to how many notifications I can send?
The Simulator does not enforce APNs rate limits for local simulations, but avoid flooding it. For realistic behavior, test with a few notifications at a time.