LeaderboardModule
ClassEnables usage of Leaderboard API within a Lens.
- Available on all platforms
Index
Extends
Properties
name
name:
string
The name of the Asset in Lens Studio.
Default Value
""
Inherited from
uniqueIdentifier
readonlyuniqueIdentifier:string
Since
Lens Scripting Version 176
Inherited from
Methods
getLeaderboard()
getLeaderboard(
options,successCallback,failureCallback):void
Gets a handle for a leaderboard.
Parameters
| Parameter | Type |
|---|---|
options | CreateOptions |
successCallback | (leaderboard) => void |
failureCallback | (message) => void |
Returns
void
getTypeName()
staticgetTypeName():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
getTypeName()
getTypeName():
string
Returns the name of this object's type.
Returns
string
Inherited from
isOfType()
isOfType(
type):boolean
Returns true if the object matches or derives from the passed in type.
Parameters
| Parameter | Type |
|---|---|
type | string |
Returns
boolean
Inherited from
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
| Parameter | Type |
|---|---|
other | ScriptObject |
Returns
boolean
Inherited from
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
| Parameter | Type |
|---|---|
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
| Parameter | Type |
|---|---|
score | number |
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.