Updated 30 November 2023
From Xcode 11.4 and onward we can test push notifications in the simulator. In this blog, we will use the two methods to test the notification.
First, we need to find the simulator identifier on which our application is installed. To find the simulator identifier we will open the terminal and run the below code.
1 |
instruments -s devices |
When we execute this code, all the installed simulators with their identifier will show. From here we will find the identifier of our simulator.
Now we will create a JSON file. In this file, we will create valid payload data. And saved it with .apns extension. Put the below code in the file and save it as anyname.apns.
1 2 3 4 5 6 7 8 9 10 11 |
{ "aps": { "alert": { "title": "This is Test title", "body": "Hello world", "sound": "default" }, "badge": 2 }, "Simulator Target Bundle": "com.test.webkul" } |
I have saved it as payload.apns
Here, “com.test.webkul” is my project bundle identifer.
We will now trigger the push notification. Simply write the below code in the terminal and execute it.
1 |
xcrun simctl push "simulator identifier" "payload data path" |
In this approach, we will simply drag and drop our payload.apns file to the simulator. As soon as we did this we can see a notification on the simulator.
You can also check other blogs from here. if you have any issues or suggestions you can leave your query/suggestion in the comment section.
If you have more details or questions, you can reply to the received confirmation email.
Back to Home
Be the first to comment.