Skip to main content

UserContextSystem

Class

Provides information about the user such as display name, birthday, and current weather.

  • Available on all platforms
Platform details: Snapchat, SPECS, Camera Kit Web, Camera Kit Mobile fully supported.

Platform details

  • Snapchat — Fully supported.

  • SPECS — Fully supported.

  • Camera Kit Web — Fully supported.

  • Camera Kit Mobile — Fully supported.

Provides information about the user such as display name, birthday, and current weather. Accessible through global.userContextSystem.

All callbacks will execute as soon as the requested information is available. In some rare cases, the requested information may be completely unavailable, and the callback will never occur.

Note that formatted or localized strings may appear differently to users depending on their region.

Index

Example

global.userContextSystem.requestDisplayName(function(displayName) {
print("Hello " + displayName);
});

global.userContextSystem.requestWeatherLocalized(function(weatherText) {
print("The weather outside is: " + weatherText);
});

global.userContextSystem.requestAltitudeFormatted(function(altitude) {
print("Your altitude is: " + altitude);
});

global.userContextSystem.requestCity(function(city) {
print("Your city is: " + city);
});

global.userContextSystem.requestBirthdateFormatted(function(birthdate) {
print("Your birthday is: " + birthdate);
});

Extends

Methods

getAllFriends()

getAllFriends(callback): void

Exposes user dataCamera Kit

Retrieve the Snapchatter's friends list in order to access details like display name, birthdate, or Bitmoji

Parameters

ParameterType
callback(data) => void

Returns

void


getAllFriendsSafeInfo()

getAllFriendsSafeInfo(callback): void

Camera Kit

Retrieve the Snapchatter's friends list with Bitmoji info only.

Parameters

ParameterType
callback(data) => void

Returns

void


getBestFriends()

getBestFriends(callback): void

Exposes user dataCamera Kit

Retrieve the Snapchatter's best friends in order to access details like display name, birthdate, or Bitmoji.

Parameters

ParameterType
callback(data) => void

Returns

void


getCurrentUser()

getCurrentUser(callback): void

Exposes user data

Retrieve a user object representing the current user. Returns a SnapchatUser in the Snapchat runtime and a SpecsUser on Spectacles (SnapOS).

Parameters

ParameterType
callback(data) => void

Returns

void


getCurrentUserSafeInfo()

getCurrentUserSafeInfo(callback): void

Retrieve the current user with Bitmoji info only.

Parameters

ParameterType
callback(data) => void

Returns

void


getFriendsWithAvailableMySelfie()

getFriendsWithAvailableMySelfie(callback): void

Exposes user dataCamera Kit

Retrieve the Snapchatter's friends who have a My Selfie identity that the current user is permitted to use for generation, in order to access details like display name, birthdate, or Bitmoji.

Parameters

ParameterType
callback(data) => void

Returns

void


getFriendsWithAvailableMySelfieSafeInfo()

getFriendsWithAvailableMySelfieSafeInfo(callback): void

Camera Kit

Retrieve the Snapchatter's friends who have a My Selfie identity that the current user is permitted to use for generation, with Bitmoji info only.

Parameters

ParameterType
callback(data) => void

Returns

void


getMyAIUser()

getMyAIUser(callback): void

Exposes user dataCamera Kit

Retrieve a user object for My AI, which you can use to access the My AI Bitmoji or other details.

Parameters

ParameterType
callback(data) => void

Returns

void


getMyAIUserSafeInfo()

getMyAIUserSafeInfo(callback): void

Camera Kit

Retrieve MyAI user with Bitmoji info only.

Parameters

ParameterType
callback(data) => void

Returns

void


getPinnedBestFriends()

getPinnedBestFriends(callback): void

Exposes user dataCamera Kit

Retrieve the Snapchatter's pinned best friends in order to access details like display name, birthdate, or Bitmoji.

Parameters

ParameterType
callback(data) => void

Returns

void


getTypeName()

static getTypeName(): TypeName<UserContextSystem>

Returns the fully-qualified JavaScript type name for this class (for example, "Component.Camera"). This is a static accessor (no instance required) and returns the same value as the instance getTypeName().

Returns

TypeName<UserContextSystem>

Overrides

ScriptObject.getTypeName


getTypeName()

getTypeName(): string

Returns the name of this object's type.

Returns

string

Inherited from

ScriptObject.getTypeName


getUsersInCurrentContext()

getUsersInCurrentContext(callback): void

Exposes user dataCamera Kit

Gets the list of friends in the current context, such as 1:1 chats, 1:many chats, and group chats.

Parameters

ParameterType
callback(data) => void

Returns

void


getUsersInCurrentContextSafeInfo()

getUsersInCurrentContextSafeInfo(callback): void

Camera Kit

Gets the list of friends in the current context with Bitmoji info only.

Parameters

ParameterType
callback(data) => void

Returns

void


isOfType()

isOfType(type): boolean

Returns true if the object matches or derives from the passed in type.

Parameters

ParameterType
typestring

Returns

boolean

Inherited from

ScriptObject.isOfType


isSame()

isSame(other): boolean

Returns true if this object is the same as other. Useful for checking if two references point to the same thing.

Parameters

ParameterType
otherScriptObject

Returns

boolean

Inherited from

ScriptObject.isSame


loadResourceAsSnapchatUser()

loadResourceAsSnapchatUser(resource, onSuccess, onFailure): void

Camera Kit

Get a user's information from a DynamicResource.

Parameters

ParameterType
resourceDynamicResource
onSuccess(snapchatUser) => void
onFailure(errorMessage) => void

Returns

void


requestAltitudeFormatted()

requestAltitudeFormatted(callback): void

Provides the user's current altitude as a localized string.

Parameters

ParameterType
callback(formattedData) => void

Returns

void


requestAltitudeInMeters()

requestAltitudeInMeters(callback): void

Provides the user's current altitude in meters.

Parameters

ParameterType
callback(data) => void

Returns

void


requestBirthdate()

requestBirthdate(callback): void

Exposes user data

Provides the user's birth date as a Date object.

Parameters

ParameterType
callback(data) => void

Returns

void


requestBirthdateFormatted()

requestBirthdateFormatted(callback): void

Exposes user data

Provides the user's birth date as localized string.

Parameters

ParameterType
callback(formattedData) => void

Returns

void


requestCity()

requestCity(callback): void

Exposes user data

Provides the name of the city the user is currently located in.

Parameters

ParameterType
callback(data) => void

Returns

void


requestDisplayName()

requestDisplayName(callback): void

Provides the user's display name.

Parameters

ParameterType
callback(data) => void

Returns

void


requestTemperatureCelsius()

requestTemperatureCelsius(callback): void

Provides the user's current temperature in celsius.

Parameters

ParameterType
callback(data) => void

Returns

void


requestTemperatureFahrenheit()

requestTemperatureFahrenheit(callback): void

Provides the user's current temperature in fahrenheit.

Parameters

ParameterType
callback(data) => void

Returns

void


requestTemperatureFormatted()

requestTemperatureFormatted(callback): void

Provides the user's current temperature as a localized string.

Parameters

ParameterType
callback(formattedData) => void

Returns

void


requestUsername()

requestUsername(callback): void

Exposes user data

Provides the user's username.

Parameters

ParameterType
callback(data) => void

Returns

void


requestWeatherCondition()

requestWeatherCondition(callback): void

Provides the user's current weather condition.

Parameters

ParameterType
callback(data) => void

Returns

void


requestWeatherLocalized()

requestWeatherLocalized(callback): void

Provides the user's current weather condition as a localized string.

Parameters

ParameterType
callback(formattedData) => void

Returns

void