iOS测在initPlugin后调用sendMsgWithSubType 在js测并没收到消息。
主要代码如下:
iOS
"sdkVersion": "1.3.25"
//iOS代码
- (void)sendMsgWithSubType:(PluginLogSubType)pluginLogSubType logString:(NSString *)string {
NSString *str = [NSString stringWithFormat:@"%@", string];
[self sendMiniPluginEvent:@{@"type":@(PluginTypeLog),@"subType":@(pluginLogSubType),@"msg": str}];
}
//JS测代码
// #if IOS
let _this = this;
const listener = (param) => {
log.info(param)
},
try {
let myPlugin = await new Promise((resolve, reject) => {
wx.miniapp.loadNativePlugin({
pluginId: PLUGIN_IOS_ID,
success: (plugin) => {
plugin.onMiniPluginEvent(listener)
log.error(`listener:${listener}, plugin:${plugin}`)
resolve(plugin)
},
fail: (err) => {
reject(err)
},
});
});
log.error('App Plugin Load success--initAppPluginbefore');
} catch (err) {
console.error('App Plugin Load fail--initAppPlugin', err);
}
// #endif