Send a Test Push

To test whether your app can receive a push directly from the Apple Push Notification service (APNs), follow these steps.

  1. Get the push token from the SDK by calling the deviceToken method and send the result to yourself via email, alert, or another method. These code examples show how to call the deviceToken method.

    For SDK version 10 or later, use this code:

    For SDK version 8, use this code:

    For SDK version 7, use this code:

  2. Trigger the APNs API directly from the command line by running a bash script. The script you run depends on whether your app uses a .p8 key or a .p12 certificate.

    This bash script points to the development APNs service by default. To trigger push from the APNs production server, change the value of the endpoint variable to https://api.push.apple.com.

After you send a test message by using the API, you can also send a test by using the Marketing Cloud Engagement user interface.

Make sure that you select the same environment MobilePush Administration page as you used to send the test message via the API. If you select Development on the MobilePush Administration page, Marketing Cloud Engagement contacts the Sandbox APNs server. If you select Production, it contacts the Production APNs server.