Name:
interface
Value:
Extend your Amplify Gen 2 app with AWS Blocks — self-contained backend capabilities you compose into your existing backend.

Push Notifications

The Amazon Connect Customer Profiles APIs let your application send profile information for the current user and manage that person's registered push devices. Devices are stored separately from the Customer Profile, in a DynamoDB device store, associated by principalId, rather than embedded inside the profile. Requests are signed with Signature Version 4 using Amazon Cognito identity pool credentials, and your backend derives the profile identity from the signed request.

These APIs are provided by AmplifyConnectClientFlutter, a standalone client in the amplify_connect_client package. It exposes three methods: identifyUser, registerDevice, and removeDevice.

This page assumes you have already deployed a notifications resource. See Set up notifications.

Install the library

Add the dependency to your pubspec.yaml:

dependencies:
amplify_connect_client: ^2.14.0

The client resolves AWS credentials through Amplify Auth, so your application also needs amplify_flutter and amplify_auth_cognito configured. See Set up Auth.

Create the client

The endpoint and Region that your backend deployed are read from the notifications.amazon_connect section of amplify_outputs.json. Create the client from the decoded outputs after configuring Amplify Auth:

import 'dart:convert';
import 'package:amplify_auth_cognito/amplify_auth_cognito.dart';
import 'package:amplify_connect_client/amplify_connect_client.dart';
import 'package:amplify_flutter/amplify_flutter.dart' hide UserProfile;
import 'package:flutter/services.dart' show rootBundle;
final raw = await rootBundle.loadString('amplify_outputs.json');
final outputs = jsonDecode(raw) as Map<String, dynamic>;
// Amplify.configure parses only its own sections, so remove the
// notifications key before configuring. The Connect client reads it
// from the decoded map instead.
final authOutputs = Map<String, dynamic>.from(outputs)..remove('notifications');
await Amplify.addPlugin(AmplifyAuthCognito());
await Amplify.configure(jsonEncode(authOutputs));
final client = AmplifyConnectClientFlutter.createFromAmplifyOutputs(
amplifyOutputs: outputs,
);

By default the client resolves credentials from Amplify Auth and persists the device identifier in shared preferences. The push channel type is resolved from the platform and build mode; pass an explicit channelType when you need to override it, for example a release-mode build that delivers through the APNs sandbox.

Call removeDevice before signing a user out. De-registration is signed with the current user's credentials, so it cannot succeed after sign-out has completed. See Remove a device.