Page updated Nov 8, 2023

Identify user to Amazon Pinpoint

This call identifies the current user (which could be unauthenticated or authenticated) to Amazon Pinpoint. The user ID can be any string which identifies the user in the context of your application.

Get the user ID from Amplify Auth

If the user is signed in through Amplify.Auth.signIn, then you can retrieve the current user's ID as shown below:

1final user = await Amplify.Auth.getCurrentUser();
2
3final userId = user.userId

Identify the user to Amazon Pinpoint

Once you have a string that identifies the current user (either from the Auth category as shown above or through your own application logic), you can identify the user to Amazon Pinpoint with the following:

1final userProfile = AWSPinpointUserProfile(
2 userAttributes: {
3 'hobbies': ['cooking', 'knitting']
4 },
5);
6
7await Amplify.Notifications.Push.identifyUser(
8 userId: userId,
9 userProfile: userProfile,
10);