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:

final user = await Amplify.Auth.getCurrentUser(); final userId = user.userId
1final user = await Amplify.Auth.getCurrentUser();
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:

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