Guides
Host features
Listen to host events and use device controls such as orientation, haptics and the deposit modal.
Listen to host events
import { WalletBridgeClient } from '@hydraone-sdk/core';
export function listen(client: WalletBridgeClient) {
const offTheme = client.onThemeChanged((theme) => console.log('theme', theme));
const offAudio = client.onAudioMutedChanged((muted) => console.log('muted', muted));
const offCustom = client.on<{ foo: string }>('CUSTOM_EVENT', (p) => console.log(p.foo));
return () => {
offTheme();
offAudio();
offCustom();
};
}
Every subscription returns an unsubscribe function. Call client.destroy() when the game shuts down; it removes all listeners.
Device and host controls
These calls ask the host shell to act:
import { WalletBridgeClient } from '@hydraone-sdk/core';
export async function device(client: WalletBridgeClient) {
await client.setOrientation('landscape');
await client.triggerHaptic('success');
await client.requestDepositModal({ token: 'ADA', minAmount: 10 });
const profile = await client.getPlayerProfile();
return profile.nickname;
}
| Call | Outside the App Center iframe |
|---|---|
setOrientation | Uses the browser API and ignores failures. |
triggerHaptic | Uses the browser API and ignores failures. |
requestDepositModal | Needs the host. Outside the App Center iframe it rejects with ERR_NOT_IN_IFRAME. |
getPlayerProfile | Asks the host for the player profile. |
Use unlockOrientation to release a lock you set earlier.
Next steps
- Testing and health checks to verify the bridge before you submit a game.
