Jerrot
Jerrot

Reputation: 338

Trigger UNNotificationServiceExtension on Simulator via Xcode 11.4 push feature

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?

Upvotes: 10

Views: 3567

Answers (2)

russbishop
russbishop

Reputation: 17219

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.

Upvotes: 9

Michael Revlis
Michael Revlis

Reputation: 1503

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.

Upvotes: 1

Related Questions