There are approx. 1.84 million apps on Apple App Store as of the fourth quarter of 2019 as per the Statista report. And, mobile app developers submit thousands of apps to the App Store on a monthly basis as per the 42matters Store Stats. To make the app out of the ordinary, app developers try new technologies with the latest trending features that help to make their app more significant to their users. Push Notification is a one such feature that is extensively used to engage with users and retain the user base of the mobile apps.
To integrate push notification in iOS apps, Apple had introduced their Apple Push Notification Service, APNs, in 2009. iOS app developers can integrate push notifications using the APNs. Despite their excellent documentation, it’s not a cake walk to integrate the push notification and requires a certain list of things to do for setting things up. Until now, developers have to use a real device to test if push notifications are working or not since push notifications weren’t supported in Xcode’s iOS Simulator.
But now, we have a good news for iOS developers, because Apple has released Xcode 11.4 Beta and the best part about this release is that we can finally test push notifications in the iOS Simulator.
Please check the release note of Xcode 11.4 beta that consists of a section saying,
Source: https://apple.co/3c0qpId
Here in this article, we’ll do a comprehensive review on what this means for developers and how to test the push notification on iOS Simulator.
Test push notifications using the Xcode command-line
First of all, you will need to download Xcode 11.4 Beta or higher from the official Apple Developer website.
Source: https://apple.co/38TqxHJ
Then you will need to create a new project to test the push notifications. You can simply create a one screen project. Then you can run the app in a simulator, here we have chosen iPhone 11, it looks like this,
Xcode command-line tools allow developers to send commands on the iOS simulator from the terminal. As mentioned in the release note of Xcode 11.4 Beta, the below command allows you to send a push notification to the iOS simulator. To get command information, here we have entered the ‘help’ command to elaborate use of each argument.
The command requires you to pass in below arguments:
<device>
You can set this to ‘booted’ to use the opened simulator. You can also set device identifier of iOS simulator which you can get with the ‘xcrun simctl list devices | grep Booted’ command or by opening the details of the simulator.
<bundle identifier>
You will need to set the bundle identifier of the app on which you’re testing push notifications. The bundle identifier is not mandatory in the command, if you add it with the ‘Simulator Target Bundle’ key in the APNs file.
<json file>
You should point this to a JSON file on disk containing the push notification details.
An example of execution could look as follows:
In this example, we’re using the following JSON saved to a payload.json file:
Please read more about the capabilities and the structure of a payload JSON on the official Apple documentation page ‘Creating the Remote Notification Payload’, https://apple.co/39UEftG
Test push notifications using an APNs file
If you are not comfortable with the command-line tools, then you can also use the second option that is mentioned in the release notes, by dragging an APNs file into the iOS simulator.
You can simply simply drag the APNs file into the iOS simulator and it will show the specific push notification.
Here, APNs file looks almost the same as the JSON payload file, but you will need to add the ‘Simulator Target Bundle’ key, describing the bundle identifier to use.
Conclusion
As per our review, this is a great extension to the upcoming versions of Xcode, because it removes lots of inconvenience caused to the iOS App Developers. Apple has provided a simple way to test push notifications on the iOS simulator. At ManekTech, our experienced iOS developers are always up to date with latest trends and releases in iOS app development. Choose our iPhone app developers from a pool of talents on-board and hire for your business needs and we will get you an outstanding iOS application.
About Author
Subscribe to Our Newsletter!
Join us to stay updated with our latest blog updates, marketing tips, service tips, trends, news and announcements!