更新记录
1.0.1(2024-11-08) 下载此版本
完善使用文档
1.0.0(2024-11-08) 下载此版本
初次发布
平台兼容性
uni-app x
Chrome | Safari | Android | iOS | 鸿蒙 | 微信小程序 |
---|---|---|---|---|---|
- | - | × | × | √ | × |
鸿蒙腾讯定位
配置权限
在鸿蒙配置文件中配置权限
{
"name": "ohos.permission.APPROXIMATELY_LOCATION",
"reason": "$string:module_desc",
"usedScene": {
"abilities": [
"EntryAbility"
],
"when": "inuse"
}
},
{
"name": "ohos.permission.LOCATION",
"reason": "$string:module_desc",
"usedScene": {
"abilities": [
"EntryAbility"
],
"when": "inuse"
}
}
使用
前往源码文件中填入自己的腾讯定位的key 源码目录 harmony-txGetLocation\utssdk\app-harmony\index.uts 94行
await TencentLocationSDK.init(context, '填写你的腾讯定位KEY', util.generateRandomUUID(true))
然后劫持掉 uni.getLocation
import * as tc from "@/uni_modules/harmony-txGetLocation";
uni.addInterceptor('getLocation', {
invoke(args) {
if (args.nav) return;
tc.getLocation({
...args,
success: args?.success,
fail: args?.fail,
complete: args?.complete
})
return false;
}
})