You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
functionsetupOrientationHandling(): CleanupFn{// Get initial orientationupdateLayout(DeviceInfo.orientation());// Listen for changesreturnDeviceInfo.onOrientationChange((orientation)=>{updateLayout(orientation);});}functionupdateLayout(orientation: Orientation): void{if(orientation==='portrait'){document.body.classList.add('portrait');document.body.classList.remove('landscape');}else{document.body.classList.add('landscape');document.body.classList.remove('portrait');}}
Orientation Lock for Games
asyncfunctioninitGame(): Promise<void>{// Try to lock to landscape for gameconstlocked=awaitDeviceInfo.lockOrientation('landscape');if(!locked){showOrientationPrompt('Please rotate your device to landscape mode');// Listen for correct orientationconstcleanup=DeviceInfo.onOrientationChange((orientation)=>{if(orientation==='landscape'){hideOrientationPrompt();cleanup();}});}startGame();}// Cleanup on exitfunctionexitGame(): void{DeviceInfo.unlockOrientation();}
functioninitLocalization(): void{constlanguages=DeviceInfo.languages();constprimaryLanguage=DeviceInfo.language();// Try to match user's preferred languagesconstsupportedLanguages=['en','de','fr','es'];for(constlangoflanguages){constlangCode=lang.split('-')[0];if(supportedLanguages.includes(langCode)){setAppLanguage(langCode);return;}}// Fall back to EnglishsetAppLanguage('en');}
Touch Device Optimization
functionoptimizeForTouch(): void{if(DeviceInfo.isTouchDevice()){// Increase tap target sizesdocument.body.classList.add('touch-optimized');// Replace hover effects with tap effectsreplaceHoverWithTap();// Enable swipe gesturesenableSwipeGestures();}}
Detection Notes
User Agent Detection - Some detection relies on user agent strings which
can be spoofed
Feature Detection Preferred - Use feature detection when possible instead
of device detection
iPadOS Detection - iPadOS 13+ reports as Macintosh; use touch detection
combination
Tablet Detection - Tablet detection uses combination of user agent and
screen size
Pixel Ratio - High pixel ratio devices may have different effective
viewport sizes