Apple has supporting push notification for simulators.
iOS 13.4 and above or Xcode 11.4 and above.
as usually create Xcode project and implement a user notification and authorization permission.
run your application in simulator iOS 13.4 and above.
put your application in background.
- Create an APNS payload file named "payload.apns"
{
"aps": {
"alert": {
"title": "Test Push",
"body": "Success! Push notification in simulator! 🎉",
"sound": "default"
},
"badge": 10
},
"Simulator Target Bundle": "com.company.app"
}
- Drag and drop to your iOS simulator.
right now your push notification will appear on simulator.
And also you can simulate push notification by terminal
get your simulator identifier by opening Window->Devices and Simulators and choose your targeted simulator and right click and copy your identifier.
Now build a terminal command like
xcrun simctl push <simulator-identifier> <path-to-payload-file>
ex:
xcrun simctl push 27A23727-45A9-4C12-BE29-8C0E6D1E5360 payload.apns
run this command and simulate push notification in simulator
mutable-content
key. See here – Rogelioroger