在module.json5文件中配置harmonyos轻量地图sdk所需的相关权限,确保sdk可以正常使用。配置如下:
"requestpermissions":[{"name":"ohos.permission.write_user_storage"},{"name":"ohos.permission.read_user_storage"},{"name":"ohos.permission.internet"},{"name":"ohos.permission.get_bundle_info"}]
在工程的oh-package.json5文件中添加依赖。配置如下:
{"license":"apache license 2.0","devdependencies":{},"name":"entry","description":"example description","version":"1.0.1","dependencies":{//添加依赖如下"@bdmap/base":"1.0.0","@bdmap/search":"1.0.0","@bdmap/map":"1.0.0"}}
在ability中调用如下代码来获取appidentifier:
/*** 获取appidentifier*/publicgetbundleappidentifier(){// 根据给定的bundle名称获取bundleinfo。// 使用此方法需要申请 ohos.permission.get_bundle_info权限。let bundleflags = bundlemanager.bundleflag.get_bundle_info_with_signature_info;try{return bundlemanager.getbundleinfoforself(bundleflags).then((data)=>{//获取appidentifierappidentifier = data.signatureinfo.appidentifier;console.info('getbundleappidentifier successfully. data: ' appidentifier );}).catch(error=>{console.error('getbundleappidentifier failed. cause: ' error.message);});}catch(error){console.error('getbundleappidentifier failed:' error.message);}}
申请所需参数:appidentifier。联系开放平台。
上一篇
下一篇
本篇文章对您是否有帮助?