LiaDevelopers

SDK reference

Lia.requestNotifications, Lia.inviteFriend, Lia.inviteLink, Lia.share and Lia.lobby.

#Notifications

Your server sends notifications with POST /notifications. Your page only asks for permission. See Notifications.

#Lia.requestNotifications()

Asks the person, in Lia's own sheet, to let your app send them notifications. If they already did, it answers at once without asking.

JavaScript
const { allowed } = await Lia.requestNotifications();

Resolves with { allowed }. Lia.notificationsAllowed is updated too.

ErrorWhen
notifications_offYour app may not send notifications (the Lia team turned them off for it).
busyAnother of Lia's screens is open.

#Invites

See Invites and links.

#Lia.inviteFriend(options)

Opens Lia's friend picker. Each friend picked gets a card in their Lia chat that opens your app with your startParam. The sheet also lets the person share your invite link anywhere.

JavaScript
const { invited } = await Lia.inviteFriend({ startParam: "room-k3x9" });
OptionType
startParamstringOptional. 1 to 64 of letters, digits, _ and -.
idempotencyKeystringOptional (SDK 1.5). With the same key, each friend gets that invite's card once. See Idempotency keys.

Resolves with { invited }: true once anyone was invited or the link was shared. Your app never learns who.

Errors: bad_start_param, bad_idempotency_key, busy.

Your app's invite link, with an optional startParam. Anyone can open it: with Lia, it opens your app with the startParam; without, it points to the App Store. Call it after Lia.init().

JavaScript
const link = Lia.inviteLink("room-k3x9");
// "https://api.lialabs.org/play/your-app?start=room-k3x9"

Returns a string (not a promise). Throws not_ready before init() has answered, and bad_start_param for a startParam that doesn't fit.

#Lia.share(text)

Opens the phone's share sheet with your text, for any app on the phone. Resolves with null once the sheet closes.

JavaScript
await Lia.share("I scored 1280 in Tilt Runner. Beat me: " + Lia.inviteLink());
ParameterType
textstringUp to 500 characters.

Errors: bad_text.

#The lobby

Public tables anyone on Lia can find (SDK 1.6). Your server lists and seats them; see Public tables.

#Lia.lobby

#Lia.lobby.tables(options)

The open tables in your app, newest first. Never the player's own tables, full or expired ones, or those of anyone they blocked or who blocked them.

JavaScript
const { tables, next } = await Lia.lobby.tables({ stake: 5 });
// [{ id: "t8k2d", game: "your-app", host: { name: "amara" }, seats: 2, taken: 1, title: "Quick game", stake: 5, pot: 0, createdAt, expiresAt }]
const more = next ? await Lia.lobby.tables({ stake: 5, cursor: next }) : null;
OptionType
stakenumberOptional. Only tables at this stake, in LIA (0 for free ones).
cursorstringOptional. next from the page before.
limitnumberOptional. 1 to 50, 20 by default.

Resolves with { tables, next }: next is the cursor for more, or null. Each table:

FieldType
idstringThe table's id, as your server listed it.
gamestringYour app's id.
hostobject{ name }: the host's Lia username.
seats, takennumberSeats in all, and taken (the host's included).
titlestring or nullUp to 40 characters.
stake, potnumberIn LIA, as your server listed them (for show).
createdAt, expiresAtnumberMilliseconds since 1970.

To sit, send the table's id to your server, which seats the player with POST /lobby/tables/:id/sit. Someone who chose your table in Lia's own lobby arrives with Lia.startParam set to lobby-<table id>: seat them the same way.

Errors: bad_stake, bad_cursor, bad_session (the session couldn't be renewed), not_in_lia.

#Lia.lobby.report(playerId, reason, options)

Reports a player to the Lia team. They're also blocked for the person reporting, so neither sees the other's tables again.

JavaScript
await Lia.lobby.report("p_3f9c0a6d1b2e4f5a6b7c", "unfair", { tableId: "t8k2d", note: "Left every game when losing" });
ParameterType
playerIdstringThe player's id in your app.
reasonstring"name", "unfair", "abuse" or "other".
options.tableIdstringOptional. The table it happened at.
options.notestringOptional, up to 300 characters.

Resolves with { reported: true }. Errors: bad_reason, unknown_player, slow_down (more than 20 reports in a day), bad_note, bad_tableId.

Type to search every page, method and endpoint.