Skip to main content

LeaderboardModule

Class

Enables usage of Leaderboard API within a Lens.

  • 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.

Index

Extends

Properties

name

name: string

The name of the Asset in Lens Studio.

Default Value

""

Inherited from

Asset.name


uniqueIdentifier

readonly uniqueIdentifier: string

Since

Lens Scripting Version 176

Inherited from

Asset.uniqueIdentifier

Methods

getLeaderboard()

getLeaderboard(options, successCallback, failureCallback): void

Gets a handle for a leaderboard.

Parameters

ParameterType
optionsCreateOptions
successCallback(leaderboard) => void
failureCallback(message) => void

Returns

void


getTypeName()

static getTypeName(): TypeName<LeaderboardModule>

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<LeaderboardModule>

Overrides

Asset.getTypeName


getTypeName()

getTypeName(): string

Returns the name of this object's type.

Returns

string

Inherited from

Asset.getTypeName


isOfType()

isOfType(type): boolean

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

Parameters

ParameterType
typestring

Returns

boolean

Inherited from

Asset.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

Asset.isSame


show()

show(onShown?, onFailure?): void

Camera Kit

Asks Snapchat to open the native leaderboard panel for this Lens. onShown is called when the panel is open. onFailure is called when the panel cannot open, for example when the Lens has no leaderboard data yet or the current camera surface cannot show the panel. On Camera Kit, the callbacks may not fire, because a Camera Kit app may not handle this request.

Parameters

ParameterType
onShown?() => void
onFailure?(message) => void

Returns

void

Since

Lens Scripting Version 387

Example

//@input Asset.LeaderboardModule leaderboardModule
script.leaderboardModule.show(function () {
print("Leaderboard shown");
}, function (message) {
print("Leaderboard not shown: " + message);
});

submitScore()

submitScore(score, onSuccess?, onFailure?): void

Camera Kit

Submits a score to this Lens's leaderboard. onSuccess is called when the score is submitted, and onFailure is called when it cannot be submitted. On Camera Kit, the callbacks may not fire, because a Camera Kit app may not handle this request.

Parameters

ParameterType
scorenumber
onSuccess?() => void
onFailure?(message) => void

Returns

void

Since

Lens Scripting Version 387

Example

//@input Asset.LeaderboardModule leaderboardModule
script.leaderboardModule.submitScore(42, function () {
print("Score submitted");
}, function (message) {
print("Score not submitted: " + message);
});

See also

Leaderboard guide.