QR Codes เฉพาะอุปกรณ์: การกำหนดเส้นทาง iOS vs Android
Smart routing by device OS: app store redirection, platform-specific landing pages, and User-Agent detection techniques.
Device-Targeted QR Codes: iOS vs Android Routing
Device-targeted dynamic QR codes route scanners to different destinations based on their operating system — most commonly directing to the correct app store.
How Device Detection Works
The redirect server examines the User-Agent HTTP header to identify the scanning device:
iPhoneoriPadin User-Agent → iOSAndroidin User-Agent → Android- Neither → Desktop or other (show fallback page)
Common Routing Patterns
App download: - iOS → Apple App Store link - Android → Google Play Store link - Desktop → Landing page with both links
Platform-specific content: - iOS → iOS-optimised web experience - Android → Android-optimised web experience
Deep linking: - App installed → Open specific screen in app (Universal Link / App Link) - App not installed → App store download page
Implementation Options
Dynamic QR platform: Most platforms offer device-based routing as a built-in feature. Configure iOS, Android, and default destinations.
Custom redirect page: Build a simple landing page with JavaScript User-Agent detection:
const ua = navigator.userAgent;
if (/iPhone|iPad/.test(ua)) {
window.location = 'https://apps.apple.com/app/id123';
} else if (/Android/.test(ua)) {
window.location = 'https://play.google.com/store/apps/details?id=com.example';
}
Smart link services: Branch, Firebase Dynamic Links, and AppsFlyer OneLink provide sophisticated device detection with deferred deep linking.
Edge Cases
- Huawei devices: May not have Google Play; consider AppGallery redirect
- Amazon Fire: Android-based but uses Amazon Appstore
- iPadOS: Detected as iPad, may need different treatment than iPhone
- Web-only scanners: Desktop browsers scanning from webcam
Key Takeaways
- User-Agent header identifies iOS, Android, and desktop devices
- Dynamic QR platforms offer device routing as a built-in feature
- Custom JavaScript redirect pages provide simple device detection
- Smart link services add deferred deep linking and advanced analytics
- Always include a desktop fallback page with links to both stores