Skip to main content

getPlatformOS

Synchronously returns the platform OS the mini-app is running on. Based on React Native's Platform.OS, it returns either 'ios' or 'android'.

Signature

import { getPlatformOS } from '@apps-in-toss/web-framework';

declare function getPlatformOS(): 'ios' | 'android';

Parameters

None.

Returns

  • 'ios' — currently running on iOS.
  • 'android' — currently running on Android.

Permission

No permission required — getPlatformOS is not bound to a PermissionName. For the typical permission flow used by other namespaces, see Guides — Permissions pattern.

Examples

Minimal

import { getPlatformOS } from '@apps-in-toss/web-framework';

const platform = getPlatformOS();
console.log('Platform:', platform); // 'ios' or 'android'

Realistic — platform-specific styles

import { getPlatformOS } from '@apps-in-toss/web-framework';

function PlatformSpecificButton() {
const platform = getPlatformOS();
const isIos = platform === 'ios';

return (
<button
type="button"
style={{
// Rounded on iOS, Material style on Android
borderRadius: isIos ? 22 : 4,
fontFamily: isIos ? '-apple-system' : 'Roboto, sans-serif',
padding: '12px 24px',
}}
>
{isIos ? 'iOS-style button' : 'Android-style button'}
</button>
);
}

Try it live

Open the Environment page in sdk-example and run the getPlatformOS card to inspect the result.

Open in sdk-example

External references