Akash Saikia
Akash Saikia

Reputation: 452

user agent checking for ios6

I am trying to check whether client opening the page is using iOS6 or not.

var startIndex = navigator.userAgent.search(/OS/i) + 2;
    var endIndex = navigator.userAgent.search(/like/i);
    var iOSVersion = parseInt(navigator.userAgent.substr(startIndex,endIndex - startIndex).trim());
    this.iOSVersion = true;

    if(!isNaN(iOSVersion)){
        this.iOSVersion = iOSVersion;
    }
    else if(Ext.is.Desktop){
        this.iOSVersion = true;
    }

The above code works well for all the versions of browsers.

But incase of using it in iOS6, it shows as iOS5. Searched for the same thing, but I didn't find a solution. May be I am still not done with searching for this, doing side by side search and hoping if some one has faced this issue before.

Any suggestions or updations?

Upvotes: 1

Views: 562

Answers (1)

Yuankai Ge
Yuankai Ge

Reputation: 81

This should work now in iOS 6 GM seed and the following regex could detect both iPhone/iPad with iOS6:

/OS (\w+) like Mac OS/i.exec(navigator.userAgent)

Upvotes: 2

Related Questions