t***@126.com
t***@126.com
  • 发布:2020-07-29 15:12
  • 更新:2020-07-29 16:23
  • 阅读:2091

iOS 无法回调数据给uni-app(使用UniMPSDK_iOS@2.8.2.20200726 demo)

分类:uni-app
iOS

uni-app 代码
// 向宿主App发送事件
uni.sendNativeEvent('unimp-event', {
msg: 'unimp message!!!'
}, ret => {
this.nativeMsg = '宿主App回传的数据:' + ret;
uni.showModal({
content:data,
showCancel: false,
});
});

iOS代码
/// 监听小程序发送的事件回调方法
/// @param event 事件
/// @param data 参数
/// @param callback 回调方法,回传数据给小程序

  • (void)onUniMPEventReceive:(NSString *)event data:(id)data callback:(DCUniMPKeepAliveCallback)callback {

    NSLog(@"Receive UniMP event: %@ data: %@",event,data);

    // 回传数据给小程序
    // DCUniMPKeepAliveCallback 用法请查看定义说明
    if (callback) {
    callback(@"native callback message",NO);
    }
    }

iOS控制台打印日志
2020-07-29 15:00:45.956189+0800 HelloUniMPDemo[15684:4831686] <Weex>[error]WXBridgeContext.m:1310, jsLog: [JS Framework] Failed to execute the callback function:
ReferenceError: Can't find variable: data __ERROR
2020-07-29 15:00:45.963235+0800 HelloUniMPDemo[15684:4831686] <Weex>[error]WXExceptionUtils.m:38, Weex exception errCode: -9400 function: func: (null) arg:(null) message: [WX_KEY_EXCEPTION_WXBRIDGE] exception: ReferenceError: Can't find variable: data
stack:app-service.js:1:5809
consume@weex-main-jsfm.js:2:1418
map@[native code]
2020-07-29 15:00:45.963711+0800 HelloUniMPDemo[15684:4831686] <Weex>[error]WXMonitor.m:289, [WX_KEY_EXCEPTION_WXBRIDGE] exception: ReferenceError: Can't find variable: data
stack:app-service.js:1:5809
consume@weex-main-jsfm.js:2:1418
map@[native code]

2020-07-29 15:12 负责人:无 分享
已邀请:
t***@126.com

t***@126.com (作者)

请忽视这个问题 我的Vue代码写的有问题

该问题目前已经被锁定, 无法添加新回复