Auth
FRVR.auth authenticates the current player against FRVR’s backend — either with a FRVR account, a platform provider (Facebook, Google Play, Apple, …), or anonymously.
Auth is the gatekeeper for cross‑device features: cloud storage, tournaments, social, leaderboards, and shop all run through it.
Minimal setup
Section titled “Minimal setup”(No extra FRVR.init() call — you’ve already called it once during startup.)
The SDK auto‑logs in from:
- A cached token in storage (if still valid), or
- The channel’s native credentials (e.g. Facebook Instant session), or
- Anonymous sign‑in, if enabled.
Reading the current session
Section titled “Reading the current session”Tokens refresh themselves in the background around 60% of their TTL — you can treat getAccessToken() as always returning a fresh one when logged in.
Explicit login
Section titled “Explicit login”Only needed if the channel doesn’t sign the user in automatically (typically web):
Or by provider credentials the channel gave you:
'frvr' and the other platform strings come from the Platform enum (Platform.FRVR, Platform.FACEBOOK_INSTANT, …), exported from the SDK package — they’re not on window.FRVR, so use the string literals here.
Registration
Section titled “Registration”With ifConflictTryLogin = true, an existing‑account error automatically degrades to a login attempt.
Anonymous
Section titled “Anonymous”Anonymous sessions still persist a stable ID. You can upgrade one to a real account later with registerOnFRVR.
Logout
Section titled “Logout”Some channels don’t allow logout (the player is always signed in via the host app) — check first.
Reacting to status changes
Section titled “Reacting to status changes”Fired on login, logout, and token refresh.
API summary
Section titled “API summary”| Method | Purpose |
|---|---|
init() | Auto‑login (called by FRVR.init). |
isLoggedIn() | Valid session present? |
isLoggingIn() | Login in progress? |
getAccessToken() | JWT for backend calls. |
getFRVRID() | Current user’s FRVR id. |
isVerified() | Email verified (FRVR accounts only). |
getCurrentPlatform() | Which provider signed in ('FRVR', 'facebook', …). |
getAvailableLoginPlatforms() | Other providers you could offer. |
loginToFRVR(req) | Explicit login. |
loginAsAnonymous() | Anonymous session. |
registerOnFRVR(creds, ifConflictTryLogin?) | Create account and log in. |
logout() | Clear session. |
isLogoutSupported() | Channel allows logout? |
addStatusChangeListener(fn) | Subscribe to session changes. |