LiaDevelopers

SDK reference

Haptics, the QR scanner, the clipboard, links, Lia's own screens, Face ID and Touch ID, and the motion sensors.

#Haptics

#Lia.haptic(kind)

A tap the person feels. Resolves with null.

JavaScript
Lia.haptic("success");
kindFeels like
"light" (the default), "medium", "heavy", "rigid", "soft"A tap, from light to heavy
"success", "warning", "error"A result
"selection"A tick, for a choice changing

An unknown kind plays "light". Each haptic is a round trip to Lia, so don't play one every frame of a game.

#Scanning and the clipboard

#Lia.scanQr(options)

Opens Lia's QR scanner over your app. Resolves with the code's text, or null if the person closed it.

JavaScript
const text = await Lia.scanQr({ text: "Scan the code on the table" });
OptionType
textstringOptional, under the scanner's window, up to 64 characters.

Errors: bad_text, busy.

#Lia.copyText(text)

Copies text to the clipboard, and Lia says it's copied. Resolves with null.

ParameterType
textstringUp to 4096 characters.

Errors: bad_text, unsupported.

#Lia.readClipboard()

The text on the clipboard, or null. On iPhone, the phone asks the person first.

JavaScript
const pasted = await Lia.readClipboard();

Opens a web page. Your frame only shows your own pages, so use this for any other site.

JavaScript
Lia.openLink("https://example.com/terms");               // in Lia's in-app browser, over your app
Lia.openLink("https://example.com", { external: true }); // outside Lia, in the phone's browser
ParameterType
urlstringAn https address, up to 2048 characters.
options.externalbooleanOpen it outside Lia.

Resolves with null once the in-app browser is closed (or straight away for external). Errors: bad_url.

Opens one of Lia's own screens. Pages close your app first (asking, if you turned closing confirmation on) and open as themselves; sheets open over your app, which stays.

JavaScript
Lia.openLiaLink("mine"); // Lia's mining sheet, over your app
screenOpensYour app
"invite"Invite friends to LiaCloses
"strides"StridesCloses
"activity"The person's activityCloses
"send"Send $LIACloses
"apps"The Apps CenterCloses
"streak"The check-in streakStays
"mine"MiningStays
"receive"Receive $LIAStays

Resolves with { closed }: true if your app closed, false if it stayed (or the person chose to stay). Errors: unknown_screen, bad_screen.

#Face ID and Touch ID

#Lia.biometric

Ask the person to confirm it's them, with the phone's Face ID, Touch ID or fingerprint, before something sensitive in your app. Your app only learns whether they passed.

#Lia.biometric.init()

Whether the phone can do it. Resolves with { available, type }: available is true when the phone has it and it's set up; type is "face", "finger" or "unknown".

#Lia.biometric.authenticate(options)

Asks the person to confirm. Resolves with { authenticated }. If they can't use biometrics, the phone may offer its passcode instead.

JavaScript
const { available } = await Lia.biometric.init();
if (available) {
  const { authenticated } = await Lia.biometric.authenticate({ reason: "Confirm it's you to open your vault" });
}
OptionType
reasonstringOptional, shown by the phone, up to 128 characters. Lia's own words when left out.

Errors: unsupported, busy, bad_reason.

#Motion

Three sensors, each with start, stop, isStarted and its latest reading. Readings arrive as events while a sensor runs; it stops when your app closes. All three are optional on phones: start() fails with unsupported where there's none.

SensorReadingUnitsEvent
Lia.accelerometerx, y, zm/s², gravity included"accelerometerChanged"
Lia.gyroscopex, y, zRotation rate, radians a second"gyroscopeChanged"
Lia.deviceOrientationalpha, beta, gammaAngles in radians"deviceOrientationChanged"
JavaScript
await Lia.deviceOrientation.start({ refreshRate: 50 });
Lia.on("deviceOrientationChanged", function (r) {
  steer(r.gamma); // tilting left and right
});
// later
Lia.deviceOrientation.stop();

#Lia.accelerometer

Member
start(options)Starts readings. options.refreshRate: 20 to 1000 ms between readings, 1000 by default. Resolves with true; also fires "accelerometerStarted". Errors: bad_refresh_rate, unsupported.
stop()Stops them. Resolves with true; also fires "accelerometerStopped".
isStartedWhether it's running.
x, y, zThe latest reading, null before the first.

#Lia.gyroscope

The same as Lia.accelerometer, with x, y and z rotation rates.

#Lia.deviceOrientation

The same, with alpha, beta and gamma.

Type to search every page, method and endpoint.