8

Xcode 11.4 (beta) allows developers to trigger push notifications on the simulator. I'm currently doing this via command-line using:

xcrun simctl push [device] [my.bundle.identifier] payload.apns

However I also have some UNNotificationServiceExtension that loads an image from an external URL given in a custom field of the payload. The image is then displayed in the notification popup. Unfortunately this extension is never called using the given command-line.

I also tried to use the bundle identifier of the extension in the command-line, but that just doesn't do anything.

I am aware that Xcode 11.4 is still in its first beta, but did anyone discover a way to trigger a notification service extension using this new feature?

Jerrot
  • 318
  • 1
  • 13
  • Please update your question with the contents of the apns file you are trying to send. – quellish Feb 10 '20 at 23:30
  • @quellish The payload does not matter in this case though. The notification itself is shown correctly (without image then) on the simulator and the extension works fine when sending the same payload to a real device. – Jerrot Feb 11 '20 at 10:36
  • I am unable to trigger the NotificationServiceExtension by dragging and dropping into the simulator. I am using latest XCode. – Kwnstantinos Nikoloutsos Jul 19 '23 at 12:31

2 Answers2

8

Certain kinds of notifications are not currently supported, including service extensions and VoIP.

edit: As of iOS 16 Simulator can get real push notifications from the APNS Sandbox environment on compatible Macs. This allows more extension types to be supported than previously. The existing local payload mechanism is also still supported.

russbishop
  • 16,587
  • 7
  • 61
  • 74
  • 1
    Does anyone have the source for this information? – razorSharp Aug 06 '22 at 13:09
  • @razorSharp As the author himself was/is working as one of the developers on the Simulator at Apple, I consider him to be a trusted source on these things. – Jerrot Jan 03 '23 at 11:05
1

Starting from Xcode 14 and iOS 16, you can send a push notification to your simulator with the Sandbox environment.

Xcode 14 Release Notes > Simulator > New Features: https://developer.apple.com/documentation/xcode-release-notes/xcode-14-release-notes

And you can debug the ServiceExtension just like what you did with the real devices. Xcode > Debug > Attach to Process > find your ServiceExtension. Then send a push again, your breakpoints on Extensions should work.

Michael Revlis
  • 1,463
  • 11
  • 14