Phonegap Build inAppBrowser event does not fire after view change in iOS 6 & 7

与世无争的帅哥 提交于 2019-12-11 07:58:03

问题


I am building a cross platform app using PhoneGap Build, version 3.3.0. The app is a news app, so requires updating of the DOM as different views are loaded. Every time this happens the old page is removed and replaced by the new view render. The app is built around backbone.js , using jQuery and Twig to render the views.

I am using the inAppBrowser to handle links to external sites, and have successfully set these up, using:

<gap:plugin name="org.apache.cordova.inappbrowser" />

in the config, and a link to

<script src="phonegap.js"></script>

in the index.html file. I am then launching the inAppBroswer using

window.open('myURL', '_blank', 'location=yes');

and this works fine the first time I use it in a session. Even if the browser is then closed and another link on the same view is selected, the browser still works.

However, in iOS 6+, if the view is then replaced by another view, then the links in the new view do not fire. The onclick event attached to the link is definitely firing (I can tell by using alerts), but the inAppBroswer does not open. However, if I exit the app and then return to it, the inAppBroswer has opened. It is as if losing the focus on the app fires off the queued event.

I have confirmed this behaviour by placing an alert in the loadstart event handler, this does not fire until exiting the app and returning to it.

I have tried keeping a persistent reference to the the inAppBrowser and destroying the instance after it has has closed. I have also tried calling the .show() method after creating the inAppBroswer instance, but none of this seems to make any difference.

Is this an issue that anyone else has come across? I could not find another question about this specific issue. This only seems to happen in iOS 6 and 7, not in Android.

Thanks


回答1:


Seem to have solved it, this article looks at the same issue (in a different context):

https://issues.apache.org/jira/browse/CB-2102

One solution that came out of this was to use iframe bridge mode. Instructions are here:

https://groups.google.com/forum/#!msg/phonegap/iNl2M57xPEA/t2BW2kBXsbYJ

I got it to work, by calling the following:

var exec = cordova.require('cordova/exec');
exec.setJsToNativeBridgeMode(exec.jsToNativeModes.IFRAME_NAV);

on the deviceready event, and this now solves the problem for my app.

Hope this helps anyone with the same issue.



来源:https://stackoverflow.com/questions/24886522/phonegap-build-inappbrowser-event-does-not-fire-after-view-change-in-ios-6-7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!