cordova-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shazron Abdullah (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (CB-2102) InAppBrowser will not open PDFs on different pages
Date Fri, 04 Jan 2013 00:14:12 GMT

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

Shazron Abdullah edited comment on CB-2102 at 1/4/13 12:12 AM:
---------------------------------------------------------------

Re-cap.

*Problem:*
This problem only occurs on iOS 6.

On iOS 6, changing the main HTML page after the InAppBrowser has been closed results in that
new page picking up the User-Agent (UA) of the InAppBrowser, not the original one. This seems
to suggest in iOS 6, on a new webpage load, it re-reads the UserAgent property of NSUserDefaults
again (and sets navigator.userAgent anew), when on iOS 5 it does not. On iOS 5, it is set
once on UIWebView instantiation.

The problem lies in our XmlHttpRequest (xhr) bridge communication. We append the User-Agent
with a value that is tied to the current Cordova view controller (CDVViewController), that
is read by the CDVURLProtocol which determines whether we handle the Cordova exec call.

The workaround suggested is to re-set the UA back to what is expected, and this was tried.
The expected UA is successfully set on InAppBrowser exit, but now, when you navigate to a
new HTML page, all exec xhr requests just disappear without reaching the native layer. Poof.
Removing the code that sets the expected UA makes the communication work again.

Setting the bridge mode to iframe makes it work again, and this does not require the UA fix:
{code}
      var exec = cordova.require('cordova/exec');
      exec.setJsToNativeBridgeMode(exec.jsToNativeModes.IFRAME_NAV);
{code}

*Recommendation:*
If you have a multi-page app, and you use InAppBrowser, and you use iOS 6, you must use iframe
bridge mode.
                
      was (Author: shazron):
    Re-cap.

*Problem:*
This problem only occurs on iOS 6.

On iOS 6, changing the main HTML page after the InAppBrowser has been closed results in that
new page picking up the User-Agent (UA) of the InAppBrowser, not the original one. This seems
to suggest in iOS 6, on a new webpage load, it re-reads the UserAgent property of NSUserDefaults
again (and sets navigator.userAgent anew), when on iOS 5 it does not. On iOS 5, it is set
once on UIWebView instantiation.

The problem lies in our XmlHttpRequest (xhr) bridge communication. We append the User-Agent
with a value that is tied to the current Cordova view controller (CDVViewController), that
is read by the CDVURLProtocol which determines whether we handle the Cordova exec call.

The workaround suggested is to re-set the UA back to what is expected, and this was tried.
The expected UA is successfully set on InAppBrowser exit, but now, when you navigate to a
new HTML page, all exec xhr requests just disappear without reaching the native layer. Poof.
Removing the code that sets the expected UA makes the communication work again.

Setting the bridge mode to iframe makes it work again, and this does not require the UA fix:
{code}
      var exec = cordova.require('cordova/exec');
      exec.setJsToNativeBridgeMode(exec.jsToNativeModes.IFRAME_NAV);
{code}

*Recommendation:*
If you have a multi-page app, and you use iOS 6, you must use iframe bridge mode.
                  
> InAppBrowser will not open PDFs on different pages
> --------------------------------------------------
>
>                 Key: CB-2102
>                 URL: https://issues.apache.org/jira/browse/CB-2102
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: CordovaJS, iOS
>    Affects Versions: 2.3.0
>         Environment: OSX Mountain Lion, xCode 4.5.2, happens on iPad simulator 5.0, 5.1,
6.0.
>            Reporter: Chad Crowell
>            Assignee: Shazron Abdullah
>            Priority: Minor
>              Labels: InAppBrowser
>             Fix For: 2.3.0
>
>
> WWW folder is here: https://dl.dropbox.com/u/119908/www.zip
> The folder structure here is setup exactly like the much more elaborate website we are
wrapping in Cordova as an "offline website browser" app for my client. This stripped down
version exhibits the same problematic behavior.
> Whichever page you view first, the PDFs on that page open in IAB just fine. Click over
to the other page and the PDFs there don't open in IAB. Doesn't matter which page you go to
first, the other page always doesn't work.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message