ReactNative调用ios原生

1.RN调用ios原生功能

#import 
@interface RNTestModule : NSObject
@end
RCT_EXPORT_MODULE(给RN调用的模块名字,若和类名保持一致可以不填);
RCT_EXPORT_METHOD(startFacewithUser:(NSDictionary*)params  callback:(RCTResponseSenderBlock)callback) {
 
}

2.RN调用ios原生UI组件

参考另一篇文章《RN调用原生UI》

3.ios调用RN完整页面功能

RN先在AppRegistry注册RNTest模块

#import 
    NSURL *jsCodeLocation;
#ifdef DEBUG
    jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.bundle?platform=ios"];
#else
    jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"outputIOS/my" withExtension:@"jsbundle"];
#endif
    RCTRootView *rootView =
      [[RCTRootView alloc] initWithBundleURL: jsCodeLocation
                                  moduleName: @"RNTest"
                           initialProperties: nil
                               launchOptions: nil];
    self.view = rootView;

你可能感兴趣的:(ReactNative调用ios原生)