React-native调用ios native代码和传参,由React-native平台发起
定义头文件
#import <Foundation/Foundation.h>
#import <React/RCTBridgeModule.h>
@interface IosFaceSdkMoudle : NSObject<RCTBridgeModule>
@end
实现
#import "IosFaceSdkMoudle.h"
#import <React/RCTConvert.h>
@implementation IosFaceSdkMoudle
// 导出模块,不添加参数即默认为这个类名
RCT_EXPORT_MODULE();
//dictionary为react-native传递过来的参数,callback为回调给react-native的回调函数
RCT_EXPORT_METHOD(initSdk:(NSDictionary *)dictionary resolver:(RCTResponseSenderBlock)callback){
NSLog(@"@ ===> initSdk execute");
NSString *test= [RCTConvert NSString:dictionary[@"test"]];
NSString *name= [RCTConvert NSString