iOS:Push Notification from Terminal to App

Lokesh Vyas
2 min readApr 21, 2022

If we need to test push notification in a simulator, without having a physical device. We can follow some easy steps to get notifications in the simulator.

1. Make .apns file for payload.
Go to the directory where you want to create and save the file and run below command.

command: touch payload.apns

2. Save your payload in payload.apns.
like :

Like this

3. For simulator identifier.

Window -> Device and simulator -> running simulator

4. Check command-line tool configuration.

Xcode -> Preferences -> Locations (for your running xcode)

5. Run the below command to get notification from the terminal.

xcrun simctl push <Simulator-Identifier> <Path-to-Payload>

xcrun simctl push 07675B8F-E569–483A-9DD2-A189710FD161 /Users/lokeshkumar/Desktop/payload.apns

6. Minimum version of Xcode is 11.6 and iOS 13.4 to test in simulator.

7. Drag and Drop

You can also drag and drop payload.apns to simulator to see the notification. Make sure the file you are using must have Simulator Target Bundle to work it correctly.

Thanks for reading🤟

--

--