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 Android application targeting at least Android SDK API level 24 with Amplify libraries integrated

Push Notifications are delivered via Firebase Cloud Messaging (FCM). In order to use FCM, you need to register your app on the Firebase console. See Setting up push notification services for more information.

Request Permissions

Android 13 (API level 33) introduces a runtime permission for sending non-exempt notifications, including Foreground Services (FGS), from your app. To enable this permission, follow these instructions.

For Android versions v12 or lower, permission modals will appear during channel creation and app startup by default. However, starting from Android v13 (API Level 33) and higher, you can control the timing of the permissions modal by using the Notifications.Push.getPermissionStatus() method. The appearance of the permissions modal will be determined by your app's target SDK version.

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 FCM when promoted:

? Choose the push notification channel to enable. APNS |  Apple Push Notifications ❯ FCM | » Firebase Push Notifications In-App Messaging Email SMS ? Provide your pinpoint resource name: `yourPinpointResourceName` ? 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) 'Y'
1? Choose the push notification channel to enable.
2 APNS |  Apple Push Notifications
3❯ FCM | » Firebase Push Notifications
4 In-App Messaging
5 Email
8? Provide your pinpoint resource name:
9 `yourPinpointResourceName`
11? 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)
12 'Y'

The CLI will prompt for your Server Key, paste the Token you copied while setting up push notification services.

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

Open build.gradle (Module :app) and add these libraries into the dependencies block.

dependencies { implementation 'com.amplifyframework:aws-auth-cognito:ANDROID_VERSION' implementation 'com.amplifyframework:aws-push-notifications-pinpoint:ANDROID_VERSION' }
1dependencies {
2 implementation 'com.amplifyframework:aws-auth-cognito:ANDROID_VERSION'
3 implementation 'com.amplifyframework:aws-push-notifications-pinpoint:ANDROID_VERSION'

Click Sync Now when prompted.

Add the following service to your app's AndroidManifest.xml file:

<application ...> ... <service android:name="com.amplifyframework.pushnotifications.pinpoint.FCMPushNotificationService" android:exported="false"> <intent-filter> <action android:name="" /> </intent-filter> </service> ... </application>
1<application ...>
2 ...
3 <service android:name="com.amplifyframework.pushnotifications.pinpoint.FCMPushNotificationService"
4 android:exported="false">
5 <intent-filter>
6 <action android:name="" />
7 </intent-filter>
8 </service>
9 ...

Initialize Amplify Push Notifications

To initialize the Amplify Push Notifications, you will use the Amplify.addPlugin() method to add the AWSCognitoAuthPlugin and the AWSPinpointPushNotificationsPlugin and then call Amplify.configure() to finish configuring Amplify. Displaying push notifications from FCM requires registering mobile devices with the FCM service. The AWSPinpointPushNotificationsPlugin takes care of registering the device with FCM during configuration, and automatically records analytics in Amazon Pinpoint.

Add the following code to your onCreate() method in your application class:

import android.util.Log; import com.amplifyframework.AmplifyException; import com.amplifyframework.auth.cognito.AWSCognitoAuthPlugin; import com.amplifyframework.core.Amplify; import com.amplifyframework.pushnotifications.pinpoint.AWSPinpointPushNotificationsPlugin;
1import android.util.Log;
2import com.amplifyframework.AmplifyException;
3import com.amplifyframework.auth.cognito.AWSCognitoAuthPlugin;
4import com.amplifyframework.core.Amplify;
5import com.amplifyframework.pushnotifications.pinpoint.AWSPinpointPushNotificationsPlugin;
Amplify.addPlugin(new AWSCognitoAuthPlugin()); Amplify.addPlugin(new AWSPinpointPushNotificationsPlugin());
1Amplify.addPlugin(new AWSCognitoAuthPlugin());
2Amplify.addPlugin(new AWSPinpointPushNotificationsPlugin());

Your class will look like this:

public class MyAmplifyApp extends Application { @Override public void onCreate() { super.onCreate(); try { // Add these lines to add the AWSCognitoAuthPlugin and AWSPinpointPushNotificationsPlugin plugins Amplify.addPlugin(new AWSCognitoAuthPlugin()); Amplify.addPlugin(new AWSPinpointPushNotificationsPlugin()); Amplify.configure(getApplicationContext()); Log.i("MyAmplifyApp", "Initialized Amplify"); } catch (AmplifyException error) { Log.e("MyAmplifyApp", "Could not initialize Amplify", error); } } }
1public class MyAmplifyApp extends Application {
2 @Override
3 public void onCreate() {
4 super.onCreate();
6 try {
7 // Add these lines to add the AWSCognitoAuthPlugin and AWSPinpointPushNotificationsPlugin plugins
8 Amplify.addPlugin(new AWSCognitoAuthPlugin());
9 Amplify.addPlugin(new AWSPinpointPushNotificationsPlugin());
10 Amplify.configure(getApplicationContext());
12 Log.i("MyAmplifyApp", "Initialized Amplify");
13 } catch (AmplifyException error) {
14 Log.e("MyAmplifyApp", "Could not initialize Amplify", error);
15 }
16 }

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

Initialized Amplify
1Initialized Amplify