Send push notifications to iOS simulator

Send push notifications to iOS simulator

2025.06.05

This page has been translated by machine translation. View original

When you want to implement handling push notifications and processing them when tapped, there's a method to receive notifications directly from APNs, but this can lead to unintended delays or not receiving notifications at the desired timing. In this article, I'll introduce a method to send push notifications to iOS simulators from the terminal.

Testing Environment

  • macOS 15.5 (24F74)
  • Xcode 16.2
  • Xcode Command Line Tools installed
  • Target app must support push notifications (Capabilities settings)
  • iOS 17.5 / iOS 18.5 simulator

Sending Push Notifications to iOS Simulator

1. Create a Push Notification Payload

Save the following file in any location. Here, we'll name the file notification.json.

{
  "aps": {
    "alert": {
      "title": "テスト通知",
      "body": "これはテスト用のプッシュ通知です"
    },
    "badge": 1,
    "sound": "default"
  },
  "app_notification_type": "quax",
  "item_id": 200
}

Payload description:

  • badge: Number for the app icon badge
  • sound: Notification sound ("default" or audio file name)
  • app_notification_type, item_id: App-specific custom data

2. Run Debug in iOS Simulator

Launch the iOS simulator and start debugging from Xcode.

3. Find the UUID of the Running Simulator

You can find this using xcrun simctl list devices | grep Booted. This command retrieves a list of currently running iOS simulators.

% xcrun simctl list devices | grep Booted
    iPhone SE (3rd generation) (3A75CEC5-1779-4C1E-A17E-E375DED83626) (Booted)

4. Send the Push Notification

Execute using the following format:

xcrun simctl push <device_id> <bundle_identifier> notification.json

For example, to send a push notification to the app jp.ch3cooh.NSEasyConnect installed on the device we just identified:

xcrun simctl push 3A75CEC5-1779-4C1E-A17E-E375DED83626 jp.ch3cooh.NSEasyConnect notification.json

You can also use booted to omit the UUID:

xcrun simctl push booted jp.ch3cooh.NSEasyConnect notification.json

However, if multiple simulators are running, this method might become unstable. For certainty, it's better to explicitly specify the UUID.

With these steps, you can send push notifications to the iOS simulator. While this is a simulator-specific feature, using this method during development allows for efficient testing of push notifications.

Share this article

FacebookHatena blogX

Related articles