why does inAppBrowser open a blank new webview which i cant close

混江龙づ霸主 提交于 2019-12-11 12:54:05

问题


This happens only sometimes and other times works as expected. I am using inAppBrowser to open a url in a new webview.

var ref = cordova.inAppBrowser.open(url, '_blank', _inAppBrowserArgs);
ref.show();

my problem is that sometimes inAppBrowser opens a new webview and doesn't load the url (no loading indicator). I just get a blank screen. If the user clicks on "Done" and retries he/she gets the same result (doesn't work) and on each attempt a new blank webview is created (without closing the previous blank one). The only solution is to kill the app. I noticed that when this happens the "loadstart" event wasn't fired. Also, no "error" event was fired.

Any suggestions? Thanks in advance.

UPDATE

found it to be an issue with the request not being sent in the plugin. this is the navigation function in the plugin (ios version):

- (void)navigateTo:(NSURL*)url
{
    NSURLRequest* request = [NSURLRequest requestWithURL:url];

    if (_userAgentLockToken != 0) {
        [self.webView loadRequest:request];
    } else {
        __weak CDVInAppBrowserViewController* weakSelf = self;
        [CDVUserAgentUtil acquireLock:^(NSInteger lockToken) {
            _userAgentLockToken = lockToken;
            [CDVUserAgentUtil setUserAgent:_userAgent lockToken:lockToken];
            [weakSelf.webView loadRequest:request];
        }];
    }
}

if I comment out all the lines except [self.webView loadRequest:request]; it works. otherwise it sometimes stops at [CDVUserAgentUtil acquireLock:^(NSInteger lockToken) { and doesn't send the request.

来源:https://stackoverflow.com/questions/37941460/why-does-inappbrowser-open-a-blank-new-webview-which-i-cant-close

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