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

Page updated Feb 21, 2024

Register a device

AWS will end support for Amazon Pinpoint on October 30, 2026,, and is no longer accepting any new users as of May 20 (see the linked doc). The guidance is to use AWS End User Messaging for push notifications and SMS, Amazon Simple Email Service for sending emails, Amazon Connect for campaigns, journeys, endpoints, and engagement analytics. Pinpoint recommends Amazon Kinesis for event collection and mobile analytics.

Register with Amazon Pinpoint

You do not need to add these APIs to your app if you want to use Amplify with Amazon Pinpoint. You should use these APIs if you are interested in supporting multiple push providers.

You can use the Amplify.Notifications.Push.registerDevice() method to register the device with Pinpoint.

class MyAppService : FirebaseMessagingService() {
// Called when a new token for the default Firebase project is generated
@Override
public void onNewToken(String token) {
super.onNewToken(token)
// Register device with Pinpoint
Amplify.Notifications.Push.registerDevice(token,
() -> Log.i("MyAmplifyApp", "Successfully registered device"),
error -> Log.e("MyAmplifyApp", "Error registering device", error)
);
}
}
class MyAppService : FirebaseMessagingService() {
// Called when a new token for the default Firebase project is generated
override fun onNewToken(token: String) {
super.onNewToken(token)
// Register device with Pinpoint
Amplify.Notifications.Push.registerDevice(token,
{ Log.i("MyAmplifyApp", "Successfully registered device") },
{ Log.e("MyAmplifyApp", "Error registering device", error) }
)
}
}
class MyAppService : FirebaseMessagingService() {
// Called when a new token for the default Firebase project is generated
override fun onNewToken(token: String) {
super.onNewToken(token)
try {
// Register device with Pinpoint
Amplify.Notifications.Push.registerDevice(token)
Log.i("MyAmplifyApp", "Successfully registered device")
} catch (error: PushNotificationsException) {
Log.e("MyAmplifyApp", "Error registering device", error)
}
}
}
class MyAppService : FirebaseMessagingService() {
// Called when a new token for the default Firebase project is generated
@Override
public void onNewToken(String token) {
super.onNewToken(token)
// Register device with Pinpoint
RxAmplify.Notifications.Push.registerDevice(token).subscribe(
() -> Log.i("MyAmplifyApp", "Successfully registered device"),
error -> Log.e("MyAmplifyApp", "Error registering device", error)
);
}
}

You must also add the custom service extension to AndroidManifest.xml in the application tag:

<service android:name=".MyAppService"
android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>