Register a device
Register with Amazon Pinpoint
You can use the Amplify.Notifications.Push.registerDevice()
method to register the device with Pinpoint.
1class MyAppService : FirebaseMessagingService() {2 // Called when a new token for the default Firebase project is generated3 @Override4 public void onNewToken(String token) {5 super.onNewToken(token)6 7 // Register device with Pinpoint8 Amplify.Notifications.Push.registerDevice(token, 9 () -> Log.i("MyAmplifyApp", "Successfully registered device"),10 error -> Log.e("MyAmplifyApp", "Error registering device", error)11 );12 }13}
You must also add the custom service extension to AndroidManifest.xml
in the application
tag:
1<service android:name=".MyAppService"2 android:exported="false">3 <intent-filter>4 <action android:name="com.google.firebase.MESSAGING_EVENT" />5 </intent-filter>6</service>