Skip to main content

APNS Push Notification Triggers

bash

Copy-paste terminal commands to fire push notifications at the iOS Simulator — alert, silent, badge, rich media, category actions, and Live Activity.

Set BUNDLE_ID to your app’s bundle identifier once, then paste any block below.

BUNDLE_ID="com.example.MyApp"

Basic alert

xcrun simctl push booted "$BUNDLE_ID" - << 'EOF'
{
  "aps": {
    "alert": { "title": "Hello", "body": "This is a test notification." },
    "sound": "default",
    "badge": 1
  }
}
EOF

Alert with subtitle

xcrun simctl push booted "$BUNDLE_ID" - << 'EOF'
{
  "aps": {
    "alert": {
      "title": "Order Shipped",
      "subtitle": "Estimated delivery: tomorrow",
      "body": "Your order #4821 is on its way."
    },
    "sound": "default",
    "badge": 2
  }
}
EOF

Silent / background push

xcrun simctl push booted "$BUNDLE_ID" - << 'EOF'
{
  "aps": {
    "content-available": 1
  }
}
EOF

Badge-only update

xcrun simctl push booted "$BUNDLE_ID" - << 'EOF'
{ "aps": { "badge": 5 } }
EOF
# Clear badge
xcrun simctl push booted "$BUNDLE_ID" - << 'EOF'
{ "aps": { "badge": 0 } }
EOF

Rich media (image / video attachment)

mutable-content: 1 tells iOS to hand the payload to your Notification Service Extension before display. Your extension downloads the URL and attaches it as a UNNotificationAttachment.

xcrun simctl push booted "$BUNDLE_ID" - << 'EOF'
{
  "aps": {
    "alert": { "title": "Photo Shared", "body": "Alex sent you a photo." },
    "sound": "default",
    "mutable-content": 1
  },
  "media-url": "https://picsum.photos/400/300",
  "media-type": "image"
}
EOF

Notification preview (thumbnail) via attachment identifier

xcrun simctl push booted "$BUNDLE_ID" - << 'EOF'
{
  "aps": {
    "alert": { "title": "New Wallpaper", "body": "Tap to preview." },
    "sound": "default",
    "mutable-content": 1
  },
  "attachment-url": "https://picsum.photos/800/600",
  "attachment-identifier": "preview-image"
}
EOF

Category with action buttons

category must match a UNNotificationCategory identifier registered in your app.

xcrun simctl push booted "$BUNDLE_ID" - << 'EOF'
{
  "aps": {
    "alert": { "title": "Friend Request", "body": "Alex wants to connect." },
    "sound": "default",
    "category": "FRIEND_REQUEST"
  },
  "sender_id": "user_42",
  "sender_name": "Alex"
}
EOF

Time-sensitive (breaks through Focus / DND)

Requires the Time Sensitive Notifications entitlement.

xcrun simctl push booted "$BUNDLE_ID" - << 'EOF'
{
  "aps": {
    "alert": { "title": "OTP Code", "body": "Your code is 391847. Expires in 5 min." },
    "sound": "default",
    "interruption-level": "time-sensitive"
  }
}
EOF

Critical alert (sounds even when muted)

Requires an explicit entitlement from Apple.

xcrun simctl push booted "$BUNDLE_ID" - << 'EOF'
{
  "aps": {
    "alert": { "title": "Server Down", "body": "prod-api-01 is not responding." },
    "sound": { "name": "default", "critical": 1, "volume": 1.0 },
    "interruption-level": "critical"
  }
}
EOF

Live Activity update

content-state keys must match your ActivityAttributes.ContentState struct.

xcrun simctl push booted "$BUNDLE_ID" - << 'EOF'
{
  "aps": {
    "timestamp": 1718764800,
    "event": "update",
    "content-state": {
      "driverName": "Kyaw",
      "eta": "6 min",
      "status": "arriving"
    },
    "alert": { "title": "Almost there", "body": "Your driver is 6 minutes away." }
  }
}
EOF
# End the Live Activity
xcrun simctl push booted "$BUNDLE_ID" - << 'EOF'
{
  "aps": {
    "timestamp": 1718764900,
    "event": "end",
    "content-state": { "driverName": "Kyaw", "eta": "0 min", "status": "delivered" },
    "dismissal-date": 1718765500
  }
}
EOF