If you were to go with this approach for detecting iPhone and iPad, you would end up with IS_IPHONE and IS_IPAD both being true if a user comes from Facebook on an iPad. The old way to identify iPhone / iPad in JavaScript: IS_IPAD = (/iPad/i) != null Note that on the iPad, the Facebook UIWebView's user agent string includes 'iPhone'. IPhone: Mozilla/5.0 (iPhone U CPU iPhone OS 5_1_1 like Mac OS X ru_RU) AppleWebKit (KHTML, like Gecko) Mobile IPad: Mozilla/5.0 (iPad U CPU iPhone OS 5_1_1 like Mac OS X en_US) AppleWebKit (KHTML, like Gecko) Mobile IPhone: Mozilla/5.0 (iPhone U CPU iPhone OS 4_1 like Mac OS X en-us) AppleWebKit/532.9 (KHTML, like Gecko) Mobile/8B117 IPad: Mozilla/5.0 (iPad CPU OS 5_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Mobile/98176 IPhone: Mozilla/5.0 (iPhone CPU iPhone OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.3 IPad: Mozilla/5.0 (iPad CPU OS 5_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9B176 Safari/7534.48.3 The main offender here is Facebook.Ĭompare these user agent strings from iOS devices: # iOS Safari This assumption is incorrect as iOS apps can and do customize their user agent. The conventional wisdom is that iOS devices have a user agent for Safari and a user agent for the UIWebView. Although the accepted solution is correct for iPhones, it will incorrectly declare both isiPhone and isiPad to be true for users visiting your site on their iPad from the Facebook app.
0 Comments
Leave a Reply. |