{ "id": "85475", "key": "TIMOB-7406", "fields": { "issuetype": { "id": "2", "description": "A new feature of the product, which has yet to be developed.", "name": "New Feature", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [ { "id": "17608", "name": "Release 6.1.0", "archived": false, "released": true, "releaseDate": "2017-05-26" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2017-02-08T06:10:10.000+0000", "created": "2012-01-25T15:35:31.000+0000", "priority": { "name": "Low", "id": "4" }, "labels": [], "versions": [ { "id": "12580", "description": "Dual Runtime 1.8.0", "name": "Release 1.8.0.1", "archived": true, "released": true, "releaseDate": "2011-12-22" }, { "id": "14137", "description": "Release 2.1.3", "name": "Release 2.1.3", "archived": true, "released": true, "releaseDate": "2012-10-03" }, { "id": "13505", "description": "Release 3.0.0", "name": "Release 3.0.0", "archived": true, "released": true, "releaseDate": "2012-12-14" } ], "issuelinks": [ { "id": "14793", "type": { "id": "10001", "name": "Cloners", "inward": "is cloned into", "outward": "is cloned from" }, "inwardIssue": { "id": "85476", "key": "TIMOB-7407", "fields": { "summary": "Android: Set a user-agent for a webview", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "priority": { "name": "High", "id": "2" }, "issuetype": { "id": "2", "description": "A new feature of the product, which has yet to be developed.", "name": "New Feature", "subtask": false } } } } ], "assignee": { "name": "vijaysingh", "key": "vijaysingh", "displayName": "Vijay Singh", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2017-02-08T21:50:31.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10206", "name": "iOS", "description": "iOS Platform" } ], "description": "h4. PROBLEM DESCRIPTION\r\nSome people are interested in being able to set the user-agent for the webview, just like the way we do with the HTTPClient. The usage will be similar to the HTTPClient's modification of the user-agent, but will allow more developers to connect webviews to special content, like twitter that recently doesn't allow you to create a webview of a timeline from our implementation (looks like they identify the agent as mobile, but since doesn't know which one is, it just breaks). \r\n\r\nh4. MORE INFO \r\n\r\nI have seen this request often in the community. ", "attachment": [], "flagged": false, "summary": "iOS: Set a user-agent for a webview", "creator": { "name": "mpmiranda", "key": "mpmiranda", "displayName": "Mauro Parra-Miranda", "active": true, "timeZone": "America/Mexico_City" }, "subtasks": [], "reporter": { "name": "mpmiranda", "key": "mpmiranda", "displayName": "Mauro Parra-Miranda", "active": true, "timeZone": "America/Mexico_City" }, "environment": null, "closedSprints": [ { "id": 404, "state": "closed", "name": "2015 Sprint 10 SDK", "startDate": "2015-05-09T00:00:53.391Z", "endDate": "2015-05-23T00:00:00.000Z", "completeDate": "2015-05-25T14:55:16.386Z", "originBoardId": 114 }, { "id": 796, "state": "closed", "name": "2017 Sprint 02 SDK", "startDate": "2017-01-15T00:00:41.845Z", "endDate": "2017-01-29T00:00:00.000Z", "completeDate": "2017-01-30T21:10:44.640Z", "originBoardId": 114 } ], "comment": { "comments": [ { "id": "213946", "author": { "name": "mofle", "key": "mofle", "displayName": "Sindre Sorhus", "active": true, "timeZone": "Europe/Oslo" }, "body": "Would be very useful.", "updateAuthor": { "name": "mofle", "key": "mofle", "displayName": "Sindre Sorhus", "active": true, "timeZone": "Europe/Oslo" }, "created": "2012-08-11T11:18:11.000+0000", "updated": "2012-08-11T11:18:11.000+0000" }, { "id": "291891", "author": { "name": "michael", "key": "michael", "displayName": "Michael Gangolf", "active": true, "timeZone": "Europe/Berlin" }, "body": "Need to use this on iOS too.\r\nPerhaps this could help to fix this issue: http://stackoverflow.com/questions/8487581/uiwebview-ios5-changing-user-agent\r\n\r\nI'm testing the module from the marketplace at the moment but a native version would be nice and since its available on android it would close this gap.", "updateAuthor": { "name": "michael", "key": "michael", "displayName": "Michael Gangolf", "active": true, "timeZone": "Europe/Berlin" }, "created": "2014-02-07T10:05:18.000+0000", "updated": "2014-02-07T10:05:18.000+0000" }, { "id": "298694", "author": { "name": "ingo", "key": "ingo", "displayName": "Ingo Muschenetz", "active": true, "timeZone": "America/Los_Angeles" }, "body": "It seems we can't find a way to do this that is exposed in iOS (changing NSUserDefaults isn't recommended). Has anyone been able to locate native functionality for doing so?", "updateAuthor": { "name": "ingo", "key": "ingo", "displayName": "Ingo Muschenetz", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2014-03-25T21:57:16.000+0000", "updated": "2014-03-25T21:57:16.000+0000" }, { "id": "396101", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "So here is what I would suggest: We could set the webview user-agent as part of the {{Ti.setUserAgent()}} method. The method is global, so it's also used for HTTP-requests and geolocation-requests. Setting it per webview would create the major problem that different webviews could have different user-agents, which is not possible, since the only way to set the user-agent in an iOS-webview is by changing the defaults for that. Let me know your thoughts on that.", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2016-09-14T09:20:53.000+0000", "updated": "2016-09-14T09:20:53.000+0000" }, { "id": "396116", "author": { "name": "ingo", "key": "ingo", "displayName": "Ingo Muschenetz", "active": true, "timeZone": "America/Los_Angeles" }, "body": "The only question I have is that perhaps you would need to set it differently for a webview than an HTTP request, since you might need to emulate a browser. I would be fine if it was the same for all webviews (so not per-webview, but webview is different than HTTP request).", "updateAuthor": { "name": "ingo", "key": "ingo", "displayName": "Ingo Muschenetz", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2016-09-14T14:19:17.000+0000", "updated": "2016-09-14T14:19:17.000+0000" }, { "id": "396117", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "Sure, it would just the same method in which the configuration per API is made (basically around [here|https://github.com/appcelerator/titanium_mobile/blob/master/iphone/Classes/TopTiModule.m#L49]. Will propose something in the next sprint.", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2016-09-14T14:24:21.000+0000", "updated": "2016-09-14T14:24:21.000+0000" }, { "id": "404512", "author": { "name": "vijaysingh", "key": "vijaysingh", "displayName": "Vijay Singh", "active": true, "timeZone": "America/Los_Angeles" }, "body": "PR: https://github.com/appcelerator/titanium_mobile/pull/8746\r\n\r\nI have created the property in TiUIWebView, to make parity with android. We can change the user agent with creation of new webview as in example code. In doc we can mention that this property is not per-webview (different from android). [~hansknoechel] Let me know your thought.\r\n\r\n{code:java}\r\nvar win = Ti.UI.createWindow({\r\n backgroundColor: '#fff'\r\n});\r\n \r\nvar btn1 = Ti.UI.createButton({\r\n\tleft: 20,\r\n\ttop: 30,\r\n title: 'Load webview 1'\r\n});\r\n \r\nvar btn2 = Ti.UI.createButton({\r\n\ttop: 30,\r\n\tright: 20,\r\n title: 'Load webview 2'\r\n});\r\n \r\nbtn1.addEventListener('click', function() {\r\nvar webview1 = Ti.UI.createWebView({\r\n\ttop: 100,\r\n left: 0,\r\n width: Ti.Platform.displayCaps.platformWidth / 2,\r\n url : 'https://developer.apple.com/library/',\r\n userAgent : 'testUserAgent'\r\n});\r\n \r\nwebview1.addEventListener('load', function(e) {\r\n Ti.API.warn('webview 1: load - ' + e.url);\r\n Ti.API.info('webview 1: User-Agent - ' + webview1.evalJS('navigator.userAgent'));\r\n});\r\n\r\nwin.add(webview1);\r\n \r\n}); \r\n \r\nbtn2.addEventListener('click', function() {\r\n var webview2 = Titanium.UI.createWebView({\r\n \ttop: 100,\r\n \tleft: Ti.Platform.displayCaps.platformWidth / 2,\r\n \twidth: Ti.Platform.displayCaps.platformWidth / 2,\r\n url : 'https://developer.apple.com/app-store/best-of-2016/',\r\n });\r\n \r\n webview2.setUserAgent('testvvs');\r\n \r\n webview2.addEventListener('load', function(e) {\r\n Ti.API.warn('webview 2: load - ' + e.url);\r\n Ti.API.info('webview 2: User-Agent - ' + webview2.evalJS('navigator.userAgent'));\r\n });\r\n win.add(webview2);\r\n});\r\n \r\nwin.add(btn2);\r\nwin.add(btn1);\r\nwin.open();\r\n{code}\r\n", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2017-01-12T10:52:54.000+0000", "updated": "2017-01-16T10:50:10.000+0000" }, { "id": "406628", "author": { "name": "ewieber", "key": "ewieber", "displayName": "Eric Wieber", "active": false, "timeZone": "America/Los_Angeles" }, "body": "FR approved by [~htbryant], verified in SDK build 6.1.0.v20170206114448.\r\nClosing as fixed.", "updateAuthor": { "name": "ewieber", "key": "ewieber", "displayName": "Eric Wieber", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2017-02-08T21:50:31.000+0000", "updated": "2017-02-08T21:50:31.000+0000" } ], "maxResults": 11, "total": 11, "startAt": 0 } } }