My Goal is to send data from iOS device to WkWebView. After researching on how to do this task I get to know that it can be done via executing JavaScript function via WkWebView, therefore, I tried calling just a simple alert function:
@interface UIWebViewController () <WKNavigationDelegate, WKUIDelegate>
@end
WKWebView *webView;
-(void)webView:(WKWebView )webView didFinishNavigation:(WKNavigation )navigation{
NSString* javascriptString = @"alert('Hi');";
[webView evaluateJavaScript:javascriptString completionHandler:nil];
}
- (void)viewDidLoad {
[super viewDidLoad];
WKWebViewConfiguration *theConfiguration = [[WKWebViewConfiguration alloc] init];
webView = [[WKWebView alloc] initWithFrame:self.view.frame configuration:theConfiguration];
webView.navigationDelegate = self;
}
Unfortunately I am not able to see any alert with that code?
Can you let me know what kind of silly mistake I am doing in the above code?