Skip to content

Commit 27f8d91

Browse files
committed
feat(playground): add dynamic device type detection for iOS/web playground
The universal playground app now detects the device type from the connected server's /interface-info API and displays device-specific configuration options accordingly. This ensures that iOS playground users can see and configure iOS device options (autoDismissKeyboard), while web users see no device-specific options. Related to #1282
1 parent 962a318 commit 27f8d91

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

apps/playground/src/App.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export default function App() {
2323
const [serverOnline, setServerOnline] = useState(false);
2424
const [isUserOperating, setIsUserOperating] = useState(false);
2525
const [isNarrowScreen, setIsNarrowScreen] = useState(false);
26+
const [deviceType, setDeviceType] = useState<'web' | 'android' | 'ios'>('web');
2627

2728
// Create PlaygroundSDK and storage provider
2829
const playgroundSDK = useMemo(() => {
@@ -50,6 +51,21 @@ export default function App() {
5051
try {
5152
const online = await playgroundSDK.checkStatus();
5253
setServerOnline(online);
54+
55+
// Get device type from server if online
56+
if (online) {
57+
try {
58+
const interfaceInfo = await playgroundSDK.getInterfaceInfo();
59+
if (interfaceInfo?.type) {
60+
const type = interfaceInfo.type.toLowerCase();
61+
if (type === 'android' || type === 'ios' || type === 'web') {
62+
setDeviceType(type as 'web' | 'android' | 'ios');
63+
}
64+
}
65+
} catch (error) {
66+
console.warn('Failed to get interface info:', error);
67+
}
68+
}
5369
} catch (error) {
5470
console.error('Failed to check server status:', error);
5571
setServerOnline(false);
@@ -145,6 +161,7 @@ export default function App() {
145161
enableScrollToBottom: true,
146162
serverMode: true,
147163
showEnvConfigReminder: true,
164+
deviceType,
148165
}}
149166
branding={{
150167
title: 'Playground',

0 commit comments

Comments
 (0)