CocoaPods trunk is moving to be read-only. Read more on the blog, there are 18 months to go.

MGXWebBridge 0.1.0

MGXWebBridge 0.1.0

Maintained by mangox.



  • By
  • mangox

MGXWebBridge

CI Status Version License Platform

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Usage

JS to Objc:

    self.bridge = [[MGXWebBridge alloc]initWithWebView:self.webView];
    [self.bridge registerObjcFuncForJS:@"liveCallHanlder"];
    __weak typeof(self) weakSelf = self;
    self.bridge.JSHander = ^id(NSString * _Nonnull funcName, NSArray * _Nonnull params) {
        NSLog(@"%@===%@",funcName,params);
        if ([funcName isEqualToString:@"liveCallHanlder"]) {
            return [weakSelf liveCallHanlder];
        }
        return nil;
    };

Objc to JS:

    NSDictionary *param = @{
                            @"name":@"lilei",
                            @"age":@"13",
                            @"sex":@"1",
                            @"friends":@[@"han",@"li"]
                            };
    //support param type: NSString , NSArray, NSDictionary
    [self.bridge invokeJSFunc:@"ajaxResult.list" params:param];

Requirements

iOS 7.0

Installation

MGXWebBridge is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'MGXWebBridge'

License

MGXWebBridge is available under the MIT license. See the LICENSE file for more info.