User Context Overview
- Snapchat: fully supported
- SPECS: partially supported
- Camera Kit Web: fully supported
- Camera Kit Mobile: fully supported
- SnapchatFully supported
- SPECSPartially supported
- No friend graph: getAllFriends, getBestFriends, getUsersInCurrentContext and getMyAIUser aren't available, so friends' and My AI's Bitmoji can't load
- Camera Kit WebFully supported
- Camera Kit MobileFully supported
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 access the system through global.userContextSystem, which will return a UserContextSystem. The UserContextSystem allows you to access various information about the user.
When building for SPECS, getCurrentUser() returns a SpecsUser, whose accountType is AccountType.Specs. SPECS accounts have no friend graph, so friendInfo is always null, and the friend lookups and the My AI user aren't available.
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.