Page updated Nov 14, 2023

Set up Amplify Push Notifications

The Push Notifications category allows you to integrate push notifications in your app with Amazon Pinpoint targeting, campaign, and journey management support. You can segment your users, trigger push notifications to your app, and record metrics in Pinpoint when users receive or open notifications. Amazon Pinpoint helps you to create messaging campaigns and journeys targeted to specific user segments or demographics and collect interaction metrics with push notifications.


An application with Amplify libraries integrated and a minimum target of any of the following:

  • iOS 13.0, using Xcode 14.1 or later.
  • macOS 10.15, using Xcode 14.1 or later.
  • tvOS 13.0, using Xcode 14.3 or later.
  • watchOS 7.0, using Xcode 14.3 or later.
  • visionOS 1.0, using Xcode 15 beta 2 or later. (Preview support - see below for more details.)

For a full example, please follow the project setup walkthrough.

visionOS support is currently in preview and can be used by targeting the visionos-preview branch. As new Xcode 15 beta versions are released, the branch will be updated with any necessary fixes on a best effort basis.

For more information on how to use the visionos-preview branch, see Platform Support.

Push Notifications are delivered via the Apple Push Notification service (APNs). In order to use APNs, you need to setup credentials (keys or certificates) and export your credentials to a p12 file. See Setting up push notification services for more information.

Testing with APNs on the iOS simulator requires an Apple Silicon Mac running macOS 13+, Xcode 14+, and iOS simulator 16+. If your development environment does not meet all these requirements, then you must run on a real device to get an APNs token.

Set Entitlements

Using Amazon Pinpoint with APNs requires the following capabilities

  • Push Notifications
  • Background Processing -> Remote Notifications (iOS/tvOS/watchOS)
  • App Sandbox -> Outgoing Connections (macOS only)

To add these capabilities:

  1. Open your Xcode project, go to project settings, select your main application target, select the Signing and Capabilities tab, and click + Capability in the upper left corner of the editor pane to bring up the Capabilities dialog.

Arrow pointing to the plus capability icon.

Xcode can be a little finicky with this step. If the Capabilities dialog is empty, try switching to a different tab and then switching back to Signing and Capabilities

  1. Type push in the filter box and double-click Push Notifications to add the capability.

The word push typed into the search bar capabilities and push notifications is a result.

  1. Repeat step 1 to open the Capabilities dialog and then type back in the filter box and double-click Background Modes to add the capability.

The word back typed into the search bar and background modes is a result.

  1. Select Change All when prompted.

  2. Under Background Modes, select Remote Notifications

Remote notifications box is selected in the background modes section.

  1. Select Change All again when prompted.

Application Delegate

APNs requires an application delegate to handle push notifications functionality via delegate methods. If your app does not already have an application delegate, you will need to create one:

  1. Create a class that subclasses NSObject and implements the UIApplicationDelegate (iOS/tvOS), WKApplicationDelegate (watchOS), or NSApplicationDelegate (macOS) protocol.
class AppDelegate: NSObject, UIApplicationDelegate { }
1class AppDelegate: NSObject, UIApplicationDelegate {
  1. Add a property to your main app struct that identifies your application delegate.
@main struct <YOUR_APP_NAME>App: App { @UIApplicationDelegateAdaptor private var appDelegate: AppDelegate // ... }
2struct <YOUR_APP_NAME>App: App {
3 @UIApplicationDelegateAdaptor private var appDelegate: AppDelegate
4 // ...

Set up backend resources

To use Push Notifications with Amplify, you have the option to either have the Amplify CLI setup resources for you, or you can use an existing Amazon Pinpoint resource in your AWS account.

Prerequisite: Install and configure the Amplify CLI

Push Notifications requires version 10.8.0+ of the Amplify CLI. You can check your current version with amplify -version and upgrade to the latest version with amplify upgrade.

To start provisioning push notification resources in the backend, go to your project directory and execute the command:

amplify add notifications
1amplify add notifications

Choose APNS when promoted:

? Choose the push notification channel to enable. ❯ APNS |  Apple Push Notifications FCM | » Firebase Push Notifications In-App Messaging Email SMS
1? Choose the push notification channel to enable.
2❯ APNS |  Apple Push Notifications
3 FCM | » Firebase Push Notifications
4 In-App Messaging
5 Email

Follow the setup prompts:

Authorizing the app for analytics events is crucial for unauthenticated users, particularly if you intend to configure Amplify or send push notifications to your users before their authentication. If authorization is declined, please keep in mind that updating the Cognito user pool would become necessary, and any subsequent updates could potentially result in the deletion of the current user data.

? Provide your pinpoint resource name: › [pinpoint_resource_name] ? Apps need authorization to send analytics events. Do you want to allow guests and unauthenticated users to send analytics events? (we recommend you allow this when getting started) (Y/n)
1? Provide your pinpoint resource name: › [pinpoint_resource_name]
2? Apps need authorization to send analytics events. Do you want to allow guests
3 and unauthenticated users to send analytics events? (we recommend you allow this
4 when getting started) (Y/n)

Choose Certificate when promoted:

? Choose authentication method used for APNs > Certificate Key
1? Choose authentication method used for APNs
2> Certificate

The CLI will prompt for your p12 certificate path, enter a path relative to the location where you ran the command.

Note: If you receive this error:

🛑 Command failed: openssl pkcs12 -in [path_to_your_cert].p12 -out [output_path].pem -nodes -passin pass: Error outputting keys and certificates
1🛑 Command failed: openssl pkcs12 -in [path_to_your_cert].p12 -out [output_path].pem -nodes -passin pass:
2Error outputting keys and certificates

Please try using LibreSSL 3.3.6 instead of OpenSSL. See issue #12969

Upon completion, amplifyconfiguration.json will be updated to reference the newly provisioned backend push notifications resources. Note that this file should already be generated for you by the Amplify CLI as a part of your project if you followed the project setup walkthrough.

Install Amplify Libraries

Swift Package Manager

  1. To install Amplify Libraries in your application, open your project in Xcode and select File > Add Packages....

  2. Enter the Amplify Library for Swift GitHub repo URL ( into the search bar and click Add Package.

Note: Up to Next Major Version should be selected from the Dependency Rule dropdown.

  1. Lastly, choose AWSPinpointPushNotificationsPlugin, AWSCognitoAuthPlugin, and Amplify. Then click Add Package.

Initialize Amplify Push Notifications

To initialize the Amplify Push Notifications, you will use the Amplify.addPlugin() method to add the AWSPinpointPushNotificationsPlugin and then call Amplify.configure() to finish configuring Amplify.

Open the main file of the application - AppDelegate.swift or <YOUR_APP_NAME>App.swift depending on the app's life cycle - and add the following import statements at the top of the file:

import Amplify import AWSCognitoAuthPlugin import AWSPinpointPushNotificationsPlugin
1import Amplify
2import AWSCognitoAuthPlugin
3import AWSPinpointPushNotificationsPlugin

In the same file, create a function to configure Amplify:

func configureAmplify() { do { try Amplify.add(plugin: AWSCognitoAuthPlugin()) try Amplify.add(plugin: AWSPinpointPushNotificationsPlugin()) try Amplify.configure() print("Initialized Amplify"); } catch { print("Could not initialize Amplify: \(error)") } }
1func configureAmplify() {
2 do {
3 try Amplify.add(plugin: AWSCognitoAuthPlugin())
4 try Amplify.add(plugin: AWSPinpointPushNotificationsPlugin())
5 try Amplify.configure()
6 print("Initialized Amplify");
7 } catch {
8 print("Could not initialize Amplify: \(error)")
9 }

Now call the configureAmplify() function in the starting point of your application.

@main struct <YOUR_APP_NAME>App: App { // add a default initializer and configure Amplify public init() { configureAmplify() } // ... }
2struct <YOUR_APP_NAME>App: App {
3 // add a default initializer and configure Amplify
4 public init() {
5 configureAmplify()
6 }
7 // ...

Upon building and running this application you should see the following in your console window:

Initialized Amplify
1Initialized Amplify