[TIMOB-1055] Android: Expose ability to set user agent for webview instances
| GitHub Issue | n/a |
|---|---|
| Type | New Feature |
| Priority | Low |
| Status | Closed |
| Resolution | Fixed |
| Resolution Date | 2011-11-08T23:47:56.000+0000 |
| Affected Version/s | Release 1.7.3 |
| Fix Version/s | Release 1.8.0 |
| Components | Android |
| Labels | module_webview, qe-testadded |
| Reporter | Jeff Haynie |
| Assignee | Hieu Pham |
| Created | 2011-04-15T02:42:43.000+0000 |
| Updated | 2013-11-25T08:48:57.000+0000 |
I was talking to someone who mentioned this shouldn't be difficult as it exists in Android, it's just a matter of adding as passthrough setting for Titanium.
This would allow us to wrap alot of iPhone only sites up.
To test this we can just verify a default user agent and try replacing it with our own, i.e.:
var win = Ti.UI.createWindow({ top: 0, left: 0, right: 0, bottom: 0 }); var webview = Ti.UI.createWebView({ url: 'http://www.google.com' }); win.add(webview); win.open(); Ti.API.debug(webview.getUserAgent()); webview.setUserAgent("custom user agent"); Ti.API.debug("should be custom user agent: " + webview.getUserAgent());We have 2 pull requests currently pending for this that need to be merged post-V8: [https://github.com/appcelerator/titanium_mobile/pull/407] [https://github.com/appcelerator/titanium_mobile/pull/583]
Closing issue Tested with Ti Studio build 1.0.8.201201262211 Ti Mob SDK 1.9.0.v20120207171634 OSX Lion 10.7.2 Nexus S OS 2.3.6 Verified that setting a custom user agent works as expected as per Marshall's test case
Anvil test case added. PR link: https://github.com/appcelerator/titanium_mobile/pull/5020