I used the WXWebComponent
code provided by weex itself, rewrote my own WebComponent
, and added a method to intercept Url requests, exposing it to weex files.
Every time when I intercept Url
from myWebView
jump to a weex
file and pop
back again, click againmyWebView
, there is no way to return the callback
event to the weex
file. And the following error message appears
WeexDemo[23225:9905854] void SendDelegateMessage(NSInvocation *): delegate (webView:decidePolicyForNavigationAction:request:frame:decisionListener:) failed to return after waiting 10 seconds. main run loop mode: kCFRunLoopDefaultMode
Post part of the code for my webView to intercept Url
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
if (_startLoadEvent) {
NSMutableDictionary<NSString *, id> *data = [NSMutableDictionary new];
[data setObject:request.URL.absoluteString ?:@"" forKey:@"url"];
[self fireEvent:@"pagestart" params:data];
}
NSString * urlAbsoluteString= [request.URL absoluteString];
NSArray <NSString *>*schemes = self.schemesCallBacks.allKeys;
for (NSString *scheme in schemes) {
NSError *error = nil;
NSRegularExpression *regExp = [NSRegularExpression regularExpressionWithPattern:scheme options:NSRegularExpressionCaseInsensitive error:&error];
if (!error) {
NSRange range = [regExp rangeOfFirstMatchInString:urlAbsoluteString options:NSMatchingReportProgress range:NSMakeRange(0, urlAbsoluteString.length)];
if (range.location != NSNotFound) {
WXCallback callBack = self.schemesCallBacks[scheme];
callBack(@{@"url": [request.URL absoluteString]});
return NO;
}
} else {
WXLog(@"created regExp error: %@", error);
}
}
return YES;
}
The value stored in self.schemesCallBacks is WXCallback? It is recommended to try WXKeepAliveCallback instead