Skip to main content
Version: 5.x
Supported on
Snapchat
Spectacles
Camera Kit

User Context System

The User Context System allows you to get information about the current user, such as their display name, birthday, current weather, their bitmoji, friends, and more!

This page lists some of the various ways you can access the User Context.

In order to protect the user’s privacy, some features will restrict the usage of certain information. For example: Connected Lenses and Remote APIs. Be sure to double-check the feature you want to use in conjunction with User Context!.

Dynamic Text

Parts of the User Context can be accessible directly within the Text component through Dynamic Text.

Available Dynamic Text types are:

  • Altitude
  • Birthday
  • City
  • Date in various formats
  • Display Name
  • Temperature
  • Weather

Custom Components

You can also use various custom components to access the user context.

  • Friends Component to get a list and info of the user's friends.
  • Bitmoji Component to get the user and their friend's Bitmoji.

Scripting

You can use User Context in many other ways through scripting.

You can acess the system through global.userContextSystem, which will return a UserContextSystem. The UserContextSystem allows you to access various information about the user.

Scripting Example

For example, if you wanted to have the Lens display "hello" when the user opens their mouth, you can do something like:

// @input Component.Text textDisplay

script.createEvent('OnMouthOpened').bind(function () {
global.userContextSystem.requestDisplayName(function (displayName) {
script.textDisplay.text = 'Hello ' + displayName + '!';
});
});

Take a look at the UserContextSystem API Page to learn more!

Was this page helpful?
Yes
No