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

Page updated May 21, 2024

Receive a device token

Amplify Flutter v1 is now in Maintenance Mode until April 30th, 2025. This means that we will continue to include updates to ensure compatibility with backend services and security. No new features will be introduced in v1.

Please use the latest version (v2) of Amplify Flutter to get started.

If you are currently using v1, follow these instructions to upgrade to v2.

Push notifications are delivered to your user's devices through a device token which uniquely identifies your app. Although Amplify will automatically register this token with Amazon Pinpoint, it can still be useful to have access to this token for your app's use cases (e.g. to send direct notifications to a specific device).

onTokenReceived

Add onTokenReceived listeners to respond to a token being received by your app.

A token will be received by your app:

  • On every app launch, including the first install
  • When a token changes (this may happen if the service invalidates the token for any reason)
void myTokenReceivedHandler(String token) {
// Do something with the received token
}
final subscription = Amplify.Notifications.Push.onTokenReceived
.listen(myTokenReceivedHandler);
// Remember to cancel the subscription when it is no longer needed
subscription.cancel();