cordova-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kevin Simpson (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CB-3360) Set custom InAppBrowser user-agent
Date Thu, 18 Sep 2014 15:11:34 GMT

    [ https://issues.apache.org/jira/browse/CB-3360?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14139039#comment-14139039
] 

Kevin Simpson commented on CB-3360:
-----------------------------------

{quote}
How did you achieve this? Is the code available anywhere?
{quote}


In the `run` method of InAppBrowser.java

{code}
                WebSettings settings = inAppWebView.getSettings();
                settings.setJavaScriptEnabled(true);
                settings.setJavaScriptCanOpenWindowsAutomatically(true);
                settings.setBuiltInZoomControls(true);
                settings.setPluginState(android.webkit.WebSettings.PluginState.ON);
                settings.setUserAgentString(thatWebView.getSettings().getUserAgentString());
// I added this line
{code}

*caveat being I haven't changed this code in over a year so the InAppBrowser code could look
completely different now.

> Set custom InAppBrowser user-agent
> ----------------------------------
>
>                 Key: CB-3360
>                 URL: https://issues.apache.org/jira/browse/CB-3360
>             Project: Apache Cordova
>          Issue Type: Improvement
>          Components: Android, BlackBerry, Plugin InAppBrowser, WP8
>    Affects Versions: 2.7.0
>         Environment: iOS, Android, WP8, BlackBerry
>            Reporter: Kevin Simpson
>            Assignee: Joe Bowser
>            Priority: Minor
>              Labels: Cordova, InAppBrowser, android
>
> Currently you can set a custom user-agent for the main Cordova webview by overriding
the init method for the DroidGap class. However, when opening a page in the InAppBrowser,
that webview will still contain the default user-agent.
> There are two solutions that I have thought of to this:
> 1. Set the user-agent of the InAppBrowser webview to whatever the user-agent in the Cordova
webview is set to. (This is what I am currently doing, as it was a one line change, but it
requires rebuilding Cordova manually)
> 2. Have some sort of configuration option to set the user-agent for the InAppBrowser.
This would allow a different user-agent from the main webview, but is also a more involved
change.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message