Platform services
Which store or OS answers each platform service in Balaur, per platform: sign-in, achievements, cloud saves, purchases, sign-in pages, and how to set each up.
On this page
A game asks the platform for a few things: who is playing, an achievement, a leaderboard, a cloud save, a purchase, a sign-in page. Balaur gives each one script call and lets the platform the game runs on answer it.
platform.*holds what every store has. The same script runs on every platform.apple.*,google.*and thesteam_*modules hold what only one has.- Where nothing answers a call, it answers
unsupported. The game goes on.
What answers where
| Service | iOS | macOS | Android | Windows, Linux | Configure |
|---|---|---|---|---|---|
platform::sign_in, player |
Game Center | Game Center, or Steam when Steam runs the game | unsupported (Play Games is planned) |
Steam when Steam runs the game | [apple] capabilities = ["game-center"]; Steam: [steam] app_id |
platform::unlock, progress, submit_score, scores |
Game Center | Game Center | unsupported |
unsupported; Steam's are in steam_user_stats |
game-center, and the ids in App Store Connect |
platform::cloud_read, cloud_write |
iCloud key-value store | iCloud key-value store | unsupported |
unsupported |
[apple] capabilities = ["icloud-kv"] and team_id |
platform::identity |
unsupported; apple::identity instead |
Steam's ticket when Steam runs the game | unsupported |
Steam's Web API ticket | [steam] app_id |
platform::set_presence |
unsupported |
unsupported |
unsupported |
unsupported |
none answers it yet |
platform::web_sign_in |
the system sheet | the system sheet | a Custom Tab | unsupported: open the page with engine::open_url |
Android: [android] schemes |
| Sign in with Apple | apple::sign_in |
apple::sign_in |
none | none | [apple] capabilities = ["sign-in-with-apple"] |
| Sign in with Google | Google's page | Google's page | google::sign_in, Android 14 and later |
Google's page | [google] server_client_id |
| Purchases | apple::purchase |
apple::purchase |
none (Play Billing is planned) | none | [apple] capabilities = ["in-app-purchase"] |
| Notifications | apple::notify, register_for_push |
the same | none | none | push: see Apple services |
| Steamworks | none | the steam_* modules |
none | the steam_* modules |
balaur export --steam |
platform::backend() names the store that answers: "apple", "steam" or
"none". Steam takes over from Game Center on a Mac when the Steam client
started the game.
When nothing answers
Every call answers on a later tick, and every answer is a map with a kind.
A call no store on this platform takes answers kind = unsupported.
- It is not an error. The editor, a desktop run with no Steam and a replay all answer that way.
- Check the
kind, and fall back: hide the achievements button, keep a save on disk, or open a sign-in page in the browser.
// scripts/profile.bs
pub class Profile {
node: Node,
}
impl Profile {
pub async fn init() {
events::listen(self.node, "platform_event");
let me = await task::wait(platform::sign_in());
if me["kind"].text() == platform::EVENT_UNSUPPORTED {
log::info("no store on {platform::backend()}: playing as a guest");
return;
}
if me["kind"].text() == platform::EVENT_SIGNED_IN {
log::info("playing as {me["alias"].text()}");
platform::unlock("first_launch");
}
}
pub fn on_platform_event(e: any) {
if e["kind"].text() == platform::EVENT_SIGNED_OUT {
log::info("signed out in the OS");
}
}
}
Setting it up
Most of it is project.toml and the store's own console.
- The engine side — the
[apple],[google],[android]and[steam]tables.balaur exportwrites the entitlements, manifest entries and files each one needs, and refuses what cannot work. - The store side — the ids, keys and clients each store hands out. Each page below says where.
- Forge's side — the certificates and profiles that sign the build, on a project's Signing tab: iOS, macOS, Android. The upload is on its Stores tab: App Store, Google Play, Steam.
| Page | Covers |
|---|---|
| Stores | the platform module: achievements, leaderboards, cloud saves, rollback |
| Apple services | Game Center, Sign in with Apple, iCloud, purchases, notifications |
| Google services | Sign in with Google, and what is planned for Play |
| Sign-in pages | platform::web_sign_in on each platform |
| Steam | the steam_* modules and balaur export --steam |
The engine never decides who a player is or whether a purchase counts. It hands the store's proof to a server, such as Gamend, which checks it with the store. Every module's full list is in the script modules reference.