Remote/Push Notification in iOS Simulator — In 10 Easy Steps

Imad Ali Mohammad
3 min readJan 13, 2022

--

Awesome! Now you can test remote notifications in Simulator by using Xcode 11.4 or later & iOS 13.4 or later. You can add Remote Notifications to iOS Simulator in 10 easy steps.

I’m excited to start this, Let’s quickly dive in…

  1. Open Xcode — Create a new iOS app as shown.
Xcode — new project

2. Choose the product name, ‘PushNotificationTest’ or your own name, also interface as ‘Storyboard’ & language as ‘Swift’ as shown.

Xcode — Product-name

3. Select project & targets, tap on ‘Signing & capabilities’ then + Capability, filter results by typing ‘background’ and add Background Modes as shown.

Capability — Background Modes

4. Enable Remote Notifications in Background Modes.

Background Modes — enable Remote Notifications

Let’s start writing the code:

5. In AppDelegate, import UserNotifications & also add protocol UNUserNotificationCenterDelegate.

import UserNotifications

6. Add the method, registerForPushNotifications() as shown.

Xcode — Register push notifications

7. Run the app, you’d asked for permission of notifications, tap to allow it.

iOS Simulator — Notification Permission

8. # PayLoad — Each notification your provider server sends to the Apple Push Notification service (APNs) includes a payload. You can consult Apple documentation here. Create a new TextEdit and add the following JSON and make sure you edit the bundle identifier as shown:

Note: You can add your app bundle identifier into the key: “Simulator Target Bundle”

Here is an example:

Payload JSON Example

9. Save it to your local machine — any name you want and remember the location, we are going to need this throughout the course of testing. I save it as payload.apns

10. Drag and drop the payload.apns on to your Simulator where your app is installed as shown:

Drag and drop payload file to the simulator
iOS Simulator — Push Notification

Hurrah! There you go, you can see the awesome notification on iOS Simulator which helps debug your app instead of depending on the iOS Device for testing.

--

--

Imad Ali Mohammad
Imad Ali Mohammad

Written by Imad Ali Mohammad

Senior iOS Engineer, Passionate about coding and building amazing apps.