Passing data to web browse in ios 8

I have an application that loads a website into a uiwebview component . I need to communicate between uiwebview and web loading and vice versa.

My application works fine in earlier versions of ios (e.g. ios 7.x, 6.x and 5.x), but now I tried with ios 8 and it does not work. I can send information from object c to javascript (using stringByEvaluatingJavaScriptFromString :), but I can not get information from javascript.

To do this, I used the same thing as here: ios passes the values ​​to my own application . I mean, I implement:

- (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType {
NSLog(@"URL: %@", [request URL]);
NSURL *URL = [request URL]; 

if ([[URL scheme] isEqualToString:@"newprotocol"]) {
    // something
    return NO;
} 
return YES;
}

When I send: newprotocol: // xxxxx, I always get around: blank

, UIWebView ios 8, . , ios 8? ?

!

+4
2

. , , window.location.href webView:shouldStartLoadWithRequest:navigationType: UIWebViewDelegate iOS 8.

: http://blog.techno-barje.fr//post/2010/10/06/UIWebView-secrets-part3-How-to-properly-call-ObjectiveC-from-Javascript/

, IFrame :

var iframe = document.createElement("IFRAME");
iframe.setAttribute("src", "js-frame:myObjectiveCFunction");
document.documentElement.appendChild(iframe);
iframe.parentNode.removeChild(iframe);
iframe = null;

EDIT: , , , YMMV. UIWebViews WKWebViews, : , . UIWebViews .

+6

SeanR, .

, , , ) : myObjectiveCFunction.

0

All Articles