# /var/log/journal

Thoughts, stories and ideas.

07th February 2020 · 2 minutes ·

Currently, when I want to test a part of an app involving a remote notification, I only have one choice: using a real device and the Apple Push Notification service (APNs). To send a notification, we need an APNs device token, which is a globally unique token that identifies a device to APNs.

And this is painful for several reasons: we need entitlement, certificate (.p12) and to rely on APNs. You can’t test locally, we need Internet access.

I used to work with NWPusher or lola, small tools, to achieve that purpose.

And I still will use them, but now we have a better one.

Starting Xcode 11.4, it is now possible to simulate remote push notifications directly within the Simulator. All the pain points listed above are now gone as it happens locally.

The best way is to use the simctl command-line tool, that provides the interface to use Simulator programmatically.

# Device

This is the device UUID on which we will send the notification. You can either specify the UUID or booted. To find the UUID of your booted Simulator, xcrun simctl list | egrep 'Booted'.

# Bundle identifier

This is the APP_PRODUCT_BUNDLE_IDENTIFIER. You can specify the bundle identifier as an argument.

You can either specify the path of the file as the last argument or use - for standard input.
We can also omit the bundle identifier by specifying it in the payload under the Simulator Target Bundle key.