问题
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