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 AmplifyConnectClient, a standalone client in the aws-connect library. It exposes three methods: identifyUser, registerDevice, and removeDevice.
Install the library
Add the dependency to your module's build.gradle.kts:
dependencies { implementation("com.amplifyframework:aws-connect:LATEST_VERSION")}The client is annotated as an experimental Amplify API, so opt in at the use site:
@OptIn(ExperimentalAmplifyApi::class)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 with a Cognito-backed credentials provider:
import com.amplifyframework.auth.CognitoCredentialsProviderimport com.amplifyframework.connect.AmplifyConnectClientimport com.amplifyframework.connect.ChannelTypeimport com.amplifyframework.connect.ConnectClientConfigurationimport com.amplifyframework.core.configuration.AmplifyOutputsimport com.amplifyframework.core.configuration.AmplifyOutputsDataimport com.amplifyframework.foundation.credentials.toAwsCredentialsProvider
val configuration = ConnectClientConfiguration.fromAmplifyOutputs( AmplifyOutputsData.deserialize(context, AmplifyOutputs(R.raw.amplify_outputs)))
val client = AmplifyConnectClient( context = applicationContext, configuration = configuration, credentialsProvider = CognitoCredentialsProvider().toAwsCredentialsProvider(), platform = "Android", appVersion = "1.0.0", channelType = ChannelType.GCM)platform and appVersion are optional strings stored on the device registration. channelType selects the push channel for this device and defaults to ChannelType.GCM; APNS and APNS_SANDBOX are also available.
You can also construct the configuration manually:
val configuration = ConnectClientConfiguration( endpoint = "https://<api-id>.execute-api.<region>.amazonaws.com", region = "us-east-1")The endpoint must be an https:// URL.