React-native向iOS、Android回传数据

https://juejin.im/post/5b20ceb16fb9a01e4f47cd49

下面是iOS向RN传递对象的代码

#import <React/RCTBridgeModule.h>

@implementation Voicesdk

RCT_EXPORT_METHOD(startRecognizer:(RCTResponseSenderBlock)callback)
{
    NSLog(@"iOS原生的startRecognizer()函数  . . .");
    self.result = [NSMutableString new];
    self._callback = callback;
    //启动识别服务
    [_iFlySpeechRecognizer startListening];
}

@end

in other function . . .

     NSArray *items = @[@"123",self.result,@"456"];


        NSLog(@"iOS原生 isLast 识别词 => %@",self.result);


        NSDictionary *diction = @{@"voiceid":@"zhaosi",


                                @"word":self.result,


                                @"err":@""};


        self._callback(@[diction]);

     //self._callback(@[items]); 传递什么类型的对象都可以

 

 

posted @ 2020-07-11 23:42  野生野鸡码农  阅读(273)  评论(0编辑  收藏  举报