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:

1let user = try await Amplify.Auth.getCurrentUser().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:

1try await Amplify.Notifications.Push.identifyUser(userId: user)

Alternatively, you can provide additional information about the user by passing a user profile:

1let userProfile = BasicUserProfile(
2 name: "Name",
3 customProperties: [
4 "attribute": "value"
5 ]
6)
7
8try await Amplify.Notifications.Push.identifyUser(
9 userId: user,
10 userProfile: userProfile
11)