Amplify has re-imagined the way frontend developers build fullstack applications. Develop and deploy without the hassle.

Messaging campaigns

You are currently viewing the AWS SDK for Mobile documentation which is a collection of low-level libraries. Use the Amplify libraries for all new app development. Learn more

You can view the Mobile SDK API reference here.

The Amazon Pinpoint console enables you to target your app users with push messaging. You can send individual messages or configure campaigns that target a group of users that match a profile that you define. For instance, you could email users that have not used the app in 30 days, or send an SMS to those that frequently use a given feature of your app.

The following steps show how to receive push notifications targeted for your app.

  1. To receive Amazon Pinpoint push notification to your app, you'll use pinpoint.notificationManager to intercept the registration of the app for notifications in the application(_:didRegisterForRemoteNotificationsWithDeviceToken:) application call back in AppDelegate.

    Then add and call a function like registerForPushNotifications() to prompt permission from the user for the app to use notifications. The following example uses the UNUserNotificationCenter framework, which is available in iOS 10.0+. Choose the right location in your app to prompt the user for permissions. In the following example the call is implemented in the application(_:didFinishLaunchingWithOptions:) event in AppDelegate. This causes the prompt to appear when the app launches.

    import UserNotifications
    // Other imports...
    class AppDelegate: UIResponder, UIApplicationDelegate {
    // Other app delegate methods...
    func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
    ) -> Bool {
    // Other didFinishLaunching code, including Pinpoint initialization...
    // Other didFinishLaunching code...
    func application(
    _ application: UIApplication,
    didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
    withDeviceToken: deviceToken)
    func application(
    _ application: UIApplication,
    didReceiveRemoteNotification userInfo: [AnyHashable: Any],
    fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void
    ) {
    fetchCompletionHandler: completionHandler
    if (application.applicationState == .active) {
    let alert = UIAlertController(
    title: "Notification Received",
    message: userInfo.description,
    preferredStyle: .alert
    alert.addAction(UIAlertAction(title: "Ok", style: .default, handler: nil))
    .rootViewController?.present(alert, animated: true, completion:nil)
    // Request user to grant permissions for the app to use notifications
    func registerForPushNotifications() {
    UNUserNotificationCenter.current().delegate = self
    UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge]) {
    (granted, error) in
    print("Permission granted: \(granted)")
    // 1. Check if permission granted
    guard granted else { return }
    // 2. Attempt registration for remote notifications on the main thread
    DispatchQueue.main.async {
    // Other app delegate methods...

    Note: If you already have push notification delegate methods, you can just add the interceptDidRegisterForRemoteNotificationsWithDeviceToken: and interceptDidReceiveRemoteNotification:fetchCompletionHandler: callbacks to Pinpoint client.

  2. In Xcode Project Navigator, choose your app name at the top, choose your app name under Targets, choose the Capabilities tab, and then turn on Push Notifications.

  3. Configure the app to run in the Release profile instead of the default Debug profile. Perform the following steps to get a notification to the device:

    1. For your app target, go to the General tab of project configuration and make sure Automatically Manage Signing check box is not selected.

    2. In the Signing (Release) section, choose the production provisioning profile you created on Apple developer console. For testing push notifications on a device, you will need an Ad Hoc Provisioning Profile configured with a Production AppStore and Ad Hoc certificate, and with the device(s) to be used for testing.

    3. In the top left corner of Xcode (where your app name is displayed next to the current build target device), choose on your app name and then select Edit Scheme, and then set Build configuration to Release

      Note: Run your app on an iPhone device to test. Push notifications are not supported on simulators.

    4. Xcode will give an error that it could not run the app, this is due to production profile apps not being allowed to debug. Click Ok and launch the app directly from the device.

    5. When prompted, chose to allow notifications for the device.

    6. To create a new campaign to send notifications to your app from the Amazon Pinpoint console run the following command from your app project folder.

      amplify notifications console
    7. Provide a campaign name, choose Next, choose Filter by standard attributes, and then choose iOS as the platform.

    8. You should see 1 device as a targeted endpoint, which is the app you are running on the iPhone device. Choose the option and then choose Next Step.

    9. Provide text for a sample title and body for push notification, and then choose Next Step.

    10. Choose Immediate, and then choose Next Step.

    11. Review the details on the screen, and then choose Launch Campaign.

    12. A notification should appear on your iPhone. You may want to try testing push notifications when your app is in the foreground as well as when it is closed.