Created
June 10, 2014 23:33
-
-
Save iteufel/77e69203f5958593f12a to your computer and use it in GitHub Desktop.
How to extend a WebView with a Custom JSContext
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//how to extend a webview with custom Javascript functions | |
..... | |
#import <JavaScriptCore/JavaScriptCore.h> | |
#import <JavaScriptCore/JSBase.h> | |
..... | |
_webview.mainFrame.javaScriptContext[@"download"] = ^(NSString *url) { | |
//do something | |
}; | |
NSMutableArray *fileList = [[NSMutableArray alloc]init]; | |
[fileList addObject:plugin.settings[@"video.mp4"]]; | |
self.mainFrame.javaScriptContext[@"file"] = fileList; | |
//now you can access in javascript the file array | |
//or run the download function | |
..... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment