User Information
There are multiple ways to identify users in a Connected Lens session through the UserInfo class – UserInfo.userId
, UserInfo.connectionId
, and UserInfo.displayName
.
UserInfo is available from a number of sources, including SessionController APIs, SyncEntity.ownerInfo
, and NetworkRoot.ownerInfo
. MessageInfo for Networked Events also includes userId and connectionId of the message sender.
UserId
UserInfo.userId
is tied to a user’s Snapchat account. If two pairs of Spectacles are paired to the same user account, the userId for those devices in the session will be the same. The userId for a given user is different in different Lenses. UserInfo.userId
is a string.
ConnectionId
UserInfo.connectionId
is tied to the device that has joined the session. UserInfo.connectionId
is unique to each connected device, and unique to each time the device joins a session. Realtime Store ownership is tied to connectionId, not userId. UserInfo.connectionId
is a string.
DisplayName
UserInfo.displayName
is the name a user chooses on their Snapchat account profile. It is consistent across devices, Lenses, and sessions. UserInfo.displayName
is a string.
Example Scenario
This is a simple example showing a situation where one user joins a Connected Lenses session on two devices at once, and another user joins on a single device. These example userIds, connectionIds, and displayNames are simplified for explanation.
Lens #1
userID | connectionID | displayName | |
---|---|---|---|
Spectacles User A | abc | 123 | Spectacles A |
Spectacles User A | abc | 456 | Spectacles A |
Spectacles User B | def | 789 | Spectacles B |
Lens #2
userID | connectionID | displayName | |
---|---|---|---|
Spectacles User A | ghi | 987 | Spectacles A |
Spectacles User A | ghi | 654 | Spectacles A |
Spectacles User B | jlk | 321 | Spectacles B |