更新记录
1.0.0(2021-11-30)
首发
平台兼容性
Android | iOS |
---|---|
× | 适用版本区间:9 - 14 |
原生插件通用使用流程:
- 购买插件,选择该插件绑定的项目。
- 在HBuilderX里找到项目,在manifest的app原生插件配置中勾选模块,如需要填写参数则参考插件作者的文档添加。
- 根据插件作者的提供的文档开发代码,在代码中引用插件,调用插件功能。
- 打包自定义基座,选择插件,得到自定义基座,然后运行时选择自定义基座,进行log输出测试。
- 开发完毕后正式云打包
付费原生插件目前不支持离线打包。
Android 离线打包原生插件另见文档 https://nativesupport.dcloud.net.cn/NativePlugin/offline_package/android
iOS 离线打包原生插件另见文档 https://nativesupport.dcloud.net.cn/NativePlugin/offline_package/ios
注意事项:使用HBuilderX2.7.14以下版本,如果同一插件且同一appid下购买并绑定了多个包名,提交云打包界面提示包名绑定不一致时,需要在HBuilderX项目中manifest.json->“App原生插件配置”->”云端插件“列表中删除该插件重新选择
引入:
let unimodule = uni.requireNativePlugin("RCUniPlugin-RCUMapsDrection");
console.log('unimodule',unimodule);//不成功打印出来的是undefined
调用:
const res = unimodule.startDirection({
type:"apple",//支持如下类型(需要提前安装相应软件):baidu,apple,iosa,google,qq
startLatitude:26.60275,
startLongitude:106.633999,
endLatitude:26.64802,
endLongitude:106.624042
});
console.log('res:',res,typeof(res));
运行结果
[Object] {"addEventListener":"function() { [native code] }","removeAllEventListeners":"function() { [native code] }...}
res:, true, string
res:, false, string//返回false(字符串类型)表示调用失败,一般是因为没安装要调用的地图软件