Boycott A.I.
Boycott A.I.

Reputation: 18871

Which other mobile browser user agents pretend to be Android and/or iPhone?

I've written a serverside script that detects the user agent of the client, then does one of three things:

  1. If it's an iOS device, send them to the Apple App Store
  2. If it's an Android, send them to Google Play
  3. Otherwise, send them to our website

It was working fine until recently, when a Windows Phone 8.1 user came along - the IEMobile 11 browser for which had this user agent:

Mozilla/5.0 (Mobile; Windows Phone 8.1; Android 4.0; ARM; Trident/7.0; Touch; rv:11.0; IEMobile/11.0; NOKIA; Lumia 630) like iPhone OS 7_0_3 Mac OS X AppleWebKit/537 (KHTML, like Gecko) Mobile Safari/537

I've now updated my script (see below) with an initial if condition to take care of this Windows Phone 8.1 IEMobile 11 browser, but I wondered if anyone knew of any other common mobile browsers (non-iOS and non-Android) that also included "Android" or "iPhone", "iPad", etc. in their user agent strings (so I can update my script accordingly)?

<?php
$web_page_url = "http://example.com/";
$google_play_url = "http://play.google.com/store/apps/details?id=com.example.myapp";
$app_store_url = "https://itunes.apple.com/gb/app/my-app/id1234567890?mt=8";

/*
 * Detect the requesting user-agent.
 * If it's Windows Phone, send them to our website.
 * If it's Android, send them to Google Play.
 * If it's iOS, send them to Apple App Store.
 * Otherwise, send them to our website.
 */
$ua = strtolower($_SERVER['HTTP_USER_AGENT']);
if (stripos($ua, 'windows phone') !== false) {

    /*
     * It's a Windows Phone (the user agent of which may also include "Android" and "iPhone")
     */
    header("Location: $web_page_url");
    exit;

}
else if (stripos($ua, 'android') !== false) {

    /*
     * It's an Android device, send them to Google Play
     */
    header("Location: $google_play_url");
    exit;

}
else if (stripos($ua, 'iphone') !== false || stripos($ua, 'ipod') !== false || stripos($ua, 'ipad') !== false) {

    /*
     * It's an iOS device, send them to Apple App Store
     */
    header("Location: $app_store_url");
    exit;

}
else {

    /*
     * It's not an Android or iPhone, so send them to the web page
     */
    header("Location: $web_page_url");
    exit;
}
?>

Upvotes: 1

Views: 2378

Answers (2)

FredyWenger
FredyWenger

Reputation: 2325

We do exactly the same in our portal (redirect the user to a mobile page, if a mobile device is detected).
I have detected some problems with the WP 8.1 user agent string. For WP with IE, set to mobile over the Internet, I also receive the "meaningful" UAS:

Mozilla/5.0 (Mobile; Windows Phone 8.1; Android 4.0; ARM; Trident/7.0; Touch; rv:11.0; IEMobile/11.0; NOKIA; Lumia 930) like iPhone OS 7_0_3 Mac OS X AppleWebKit/537 (KHTML, like Gecko) Mobile Safari/537

Whereby, if IE mobile is set to "Desktop" or the portal is called over the Intranet, I receive:

Mozilla/5.0 (Windows NT 6.2; ARM; Trident/7.0; Touch; rv:11.0; WPDesktop; Lumia 930) like Gecko

So.. the effect was, that our portal has showed the mobile page to iOS, instead of the mobile page to WP. The workaround was to query the UAS for "Windows Phone" before the query for iPhone. It seems as MS tries, to be detected as mobile device on this way (if a page only queries for iOS and Android-devices), what is not nice.

So my (actual) code (VB.net) to the If:

If AT("Windows Phone", cProtUserAgent) > 0 Then
    cMobilePlattform = "WP"
 ElseIf AT("WPDesktop", cProtUserAgent) > 0 Then
    cMobilePlattform = "WP"
 ElseIf AT("IEMobile", cProtUserAgent) > 0 Then
    cMobilePlattform = "WP"
 ElseIf AT("ZuneWP7", cProtUserAgent) > 0 Then
    cMobilePlattform = "WP"
 ElseIf AT("iPhone", cProtUserAgent) > 0 Then
    cMobilePlattform = "iOS"
 ElseIf AT("iPad", cProtUserAgent) > 0 Then 
    cMobilePlattform = "iOS"
 ElseIf AT("Android", cProtUserAgent) > 0 Then ' Android:
     cMobilePlattform = "Android" 
 End If

Note: At returns the position od the string (if it is found, else 0).
Then, a second if take place and redirects the client to the related mobile page, if "iOS" or "Android" or "WP" is set.
Else the portal is loaded for a standard browser.

Upvotes: 0

milez
milez

Reputation: 2201

There is Tizen, a Linux based mobile OS, that uses

Mozilla/5.0 (Linux; Tizen 2.2; SAMSUNG SM-Z9005) AppleWebKit/537.3 (KHTML, like Gecko) Version/2.2 like Android 4.1; Mobile Safari/537.3

The emerging Firefox OS seems to do this also

Mozilla/5.0 (Linux; U; Android 4.4 Andro-id Build/KRT16S; X11; FxOS armv7I rv:29.0) MyWebkit/537.51.1 (KHTML, like Gecko) Gecko/29.0 Firefox/29.0 Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_9_1; en-ID) MyWebKit/537.51.1 (KHTML, like Gecko) Chrome/34.0.17

I also found this list which might be useful but is laborsome to go through manually :)

Upvotes: 2

Related Questions