Skip to main content

User Information

Access information about connected users including display names, user IDs, and connection IDs using the Sync Kit UserInfo system.

  • Snapchat: not supported
  • SPECS: fully supported
  • Camera Kit Web: not supported
  • Camera Kit Mobile: not supported
1 platform note
  • SnapchatNot supported
  • SPECSFully supported
  • Camera Kit WebNot supported
  • Camera Kit MobileNot supported

Platform details

  • Snapchat — Not supported. See Session Controller

  • SPECS — Fully supported.

  • Camera Kit Web — Not supported.

  • Camera Kit Mobile — Not supported.

You can identify users in a Connected Lens session in multiple ways 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 SPECS devices 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.

SpecsUser

You can also get a SpecsUser for any user in the session with SessionController.getSpecsUser(userInfo, callback). A SpecsUser also has userName, hasBitmoji, birthday, and zodiac.

For the local user, these come from their SPECS account, and birthday and zodiac are null if the account has no birth date. For other users in the session, only displayName and Bitmoji information are available: userName is empty, and birthday and zodiac are null.

A SpecsUser can be used in Bitmoji surfaces such as Bitmoji Module. This is useful for showing a user's Bitmoji in a Connected Lens session.

Important: The callback receives null in mocked singleplayer mode, since there is no user information available, and when there is no session yet.

import { SessionController } from 'SyncKit.lspkg/Core/SessionController';

@component
export class GetSpecsUserInfo extends BaseScriptComponent {
private sessionController: SessionController =
SessionController.getInstance();
onAwake() {
this.sessionController.notifyOnReady(() => this.onReady());
}

private onReady(): void {
const localUserInfo = this.sessionController.getLocalUserInfo();
if (!localUserInfo) {
print('No local user info available');
return;
} else {
print('Local user info available: ' + JSON.stringify(localUserInfo));
}

// Get the SpecsUser for the local user
this.sessionController.getSpecsUser(
localUserInfo,
(specsUser: SpecsUser | null) => {
if (!specsUser) {
print('getSpecsUser returned null (expected in singleplayer mode)');
return;
}

const name = specsUser.displayName || specsUser.userName || '<unknown>';
print(
'Got SpecsUser: ' + name + ', hasBitmoji=' + specsUser.hasBitmoji
);
}
);
}
}

Example Scenario

This is a straightforward 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

UseruserIdconnectionIddisplayName
User AuserA123User A
User AuserA456User A
User BuserB789User B

Lens #2

UseruserIdconnectionIddisplayName
User AuserA987User A
User AuserA654User A
User BuserB321User B