WebViewProxy
@interface WebViewProxy : NSObject <UIWebViewDelegate>
@brief A class that intercepts and redirects calls from JS code running in a UIWebView to an object that will evaluate whether the call is a web page loading call or an invocation for a method in the native environment. The proxy object also allows calling a JS method in the web view from the native side.
-
A UIWebView instance
Declaration
Objective-C
@property (assign, readwrite, atomic) UIWebView *webView;Swift
var webView: UnsafeMutablePointer
-
Initialise a WebViewProxy object with a webview and a handler for invocation requests
Declaration
Objective-C
- (id)initWithWebView:(UIWebView *)webView withInvocationHandler:(id<InvocationProcessor>)invocator;Swift
init!(webView: Any!, withInvocationHandler invocator: InvocationProcessor!)Parameters
webViewa UIWebView instance
invocatoran object that implements the InvocationProcessor. This object will handle the invocation requests coming from the web view and call the appropriate method on the native side.
Return Value
a WebViewProxy instance.
-
Loads page from a given folder. Supports only simple file and folder names. Does not support name with folder path. Valid usage - loadPage:@
index.html
fromFolder:@www
Declaration
Objective-C
- (void)loadPage:(NSString *)pageName fromFolder:(NSString *)folderName;Swift
func loadPage(_ pageName: String!, fromFolder folderName: String!)Parameters
pageNamefile name
folderNamefolder name
-
Loads web page pointed to by URL in the UIWebView instance it holds a reference to.
Declaration
Objective-C
- (void)loadUrl:(NSString *)url;Swift
func loadUrl(_ url: String!)Parameters
urla URL string.
-
create an NSError object.
Declaration
Objective-C
- (void)createError:(NSError **)error withCode:(int)code withMessage:(NSString *)msg;Swift
func createError(_ error: NSErrorPointer, withCode code: Int32, withMessage msg: String!)Parameters
errorerror object
codeerror code
msgerror message
-
Call a JS function on the webpage in the UIWebView instance.
Declaration
Objective-C
- (void)callJSFunction:(NSString *)name withArgs:(NSDictionary *)args;Swift
func callJSFunction(_ name: String!, withArgs args: [AnyHashable : Any]!)Parameters
nameJS function name
argsa dictionary of argument name-value pairs.
View on GitHub
WebViewProxy Class Reference