We have been using this as part of our communication between the UIWebView and Objc. Yes, we plan to convert to WKWebView, but have a more urgent need to fix our existing so we don't break the 3rd party Apps using our code today.
Simple Example: This works in the Simulator iOS 9.3 but not in iOS 10.x. We also tested on an iPhone with the latest iOS 10 beta.
One View App, view is UIWebView.
This should display:
2016-09-02 10:00:50.032 JSBridge[12122:26649637] http://google.com/
2016-09-02 10:00:50.037 JSBridge[12122:26649637] JSBridge://ReadNotificationWithId=0
Code Snippet example (ViewController.m)
#import "ViewController.h"
@interface ViewController () <UIWebViewDelegate>
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
UIWebView *webView = (UIWebView *)self.view;
webView.delegate = self;
[webView loadHTMLString:@"<iframe src=\"JSBridge://ReadNotificationWithId=0\"/>"
baseURL:[NSURL URLWithString:@"http://google.com"]];
}
-(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
NSLog(@"%@", request.URL);
return ![request.URL.absoluteString containsString:@"JSBridge"];
}
@end