Opened 14 months ago

Closed 14 months ago

Last modified 14 months ago

#3753 closed Bug (fixed)

UserAgent detection inside iOS App (UIWebView) gives the wrong version number

Reported by: solunic2 Owned by: Anthon Pang
Priority: low Milestone: 1.11 - Piwik 1.11
Component: Core Keywords:
Cc: Sensitive: no

Description

When a visitor comes from inside an iOS App (when a page is loaded into a UIWebView), Piwik detects the Browser as Safari, but the Version is detected wrong.

iOS 5.x: Safari 5.0 (should be 5.1)
iOS 6.x: Safari 5.1 (should be 6.0)

Safari and UIWebView give mostly the same User Agent, but UIWebView is missing Version/* and Safari/*.

I think this is the reason that

iOS 5.0
UIWebView: Mozilla/5.0 (iPhone Simulator; CPU iPhone OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Mobile/9A334
Safari:    Mozilla/5.0 (iPhone Simulator; CPU iPhone OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.3

iOS 5.1
UIWebView: Mozilla/5.0 (iPhone Simulator; CPU iPhone OS 5_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Mobile/9B176
Safari:    Mozilla/5.0 (iPhone Simulator; CPU iPhone OS 5_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9B176 Safari/7534.48.3

iOS 6.0
UIWebView: Mozilla/5.0 (iPhone; CPU iPhone OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Mobile/10A403
Safari:    Mozilla/5.0 (iPhone; CPU iPhone OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A403 Safari/8536.25

iOS 6.1
UIWebView: Mozilla/5.0 (iPhone; CPU iPhone OS 6_1 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Mobile/10B141
Safari:    Mozilla/5.0 (iPhone; CPU iPhone OS 6_1 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10B141 Safari/8536.25

Change History (4)

comment:1 Changed 14 months ago by solunic2

I will try to fix this and submit a pull request on github.

comment:2 Changed 14 months ago by matt (mattab)

  • Milestone set to 1.11 - Piwik 1.11

THanks for providing a fix. Also please update unit tests UserSettingsTest

comment:3 Changed 14 months ago by vipsoft (robocoder)

  • Owner set to Anthon Pang
  • Resolution set to fixed
  • Status changed from new to closed

In 688f171742ed9a28c44c5a6f0a4b735230a55285:

fix #3753 - fix UserAgent detection for UIWebView

comment:4 Changed 14 months ago by Fabian Becker

In 961b558cd699c333fe2bfd3e612fa5437ef3c26e:

fix #3753 - fix UserAgent detection for UIWebView

Note: See TracTickets for help on using tickets.