LiaDevelopers

Concepts

Bring friends into your app with Lia's friend picker, or a link anyone can open. Both open your app with a startParam, so friends land in the same match or room.

#Two ways in

Lia.inviteFriend()Lia.inviteLink()
What it isLia's friend pickerA link to your app
ReachesThe person's Lia friends, as a card in their Lia chatAnyone you share it with, anywhere
OpensYour app in Lia, with your startParamYour app in Lia, with your startParam, or the App Store without Lia
Answers{ invited }: whether anyone was invitedThe link, straight away

#The startParam

A startParam is how an invite says where to go: your match, room, table or anything else. It's 1 to 64 characters of letters, digits, _ and -. When someone opens your app from an invite, a link or a notification, Lia.startParam holds it. If your app is already open, your page hears a startParam event instead.

JavaScript
// Make a room on your server, then invite into it.
const room = await createRoom(); // "room-k3x9"
await Lia.inviteFriend({ startParam: room });

// Whoever opens the invite lands in the same room.
Lia.init().then(function () {
  if (Lia.startParam) joinRoom(Lia.startParam);
  Lia.ready();
});
Lia.on("startParam", function (data) { if (data.startParam) joinRoom(data.startParam); });

Treat a startParam as a hint from anyone: check on your server that the room exists and the player may join it.

#The friend picker

Lia.inviteFriend() opens Lia's own sheet over your app, with the person's friends and a way to share the link elsewhere. Each friend they pick gets a card in their Lia chat that opens your app. Your app only hears whether anyone was invited (or the link was shared), never who.

Lia keeps it friendly:

  • Friends only. People can only invite their Lia friends, and not anyone either of them has blocked.
  • Who can open it. While your app is in test, only your testers can be invited.
  • 20 a day. One person can invite at most 20 friends into your app a day.

Lia.inviteLink(startParam) gives you a link like:

Text
https://api.lialabs.org/play/your-app?start=room-k3x9

Opened on a phone with Lia, it opens your app with the startParam. Without Lia, it shows a page in the phone's language with a way to get Lia. Call it after Lia.init(); without a startParam it's a link to your app itself.

JavaScript
const link = Lia.inviteLink(room);
await Lia.share("Play with me: " + link);
// or
await Lia.copyText(link);

Multiplayer with invites builds a two player room from start to finish.

Type to search every page, method and endpoint.