NativeScript / NativeScript/plugins
[Android] [@nativescript/geolocation] Cannot watch location. Call "enableLocationRequest" first
未关闭
还没有人认领这个 Issue。
- 主要语言
- TypeScript
- 星标
- 206
- 派生
- 123
- 平均合并
- 2 天 1 小时
- 30 天内合并 PR
- 1
描述
I call watchLocation properly after enableLocationRequest but I am getting Cannot watch location. Call "enableLocationRequest" first error message.
Other weird behavior:
- It seems even if I allow the location permission, it forgets and requests it again.
- the docs says watchLocation is now async in order to check for permissions before attempting to watch but this is meaningless this way, since still the callback sends the location, this part is very unclear, and I couldn't find any examples for v9
✔ Component nativescript has 8.8.2 version and is up to date.
✔ Component @nativescript/core has 8.8.6 version and is up to date.
✖ Component @nativescript/ios is not installed.
✔ Component @nativescript/android has 8.8.6 version and is up to date.
"@nativescript/geolocation": "^9.0.0",
Code:
Geolocation.enableLocationRequest(true, true).then(() => {
Geolocation.watchLocation(
location => {
console.log(location);
},
e => {
console.log('watchLocation ERROR:', e);
},
{
//Specifies desired accuracy in meters.
desiredAccuracy: CoreTypes.Accuracy.any,
updateDistance: 300,
updateTime: 10000,
minimumUpdateTime: 1000
}
).then(()=>{
console.log('WHAT IS THIS FOR?')
})
UPDATE:
Downgrading to 8.3.1 solved all the issues and everything is working. I am on API 35.
So this is clearly a bug with 9.0.0 or the documentation is inaccurate and I should do something differently.
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先在 Android API 35 上使用 @nativescript/geolocation 9.0.0 重现该示例,然后将其行为与 8.3.1 版本进行比较。检查 enableLocationRequest 和 watchLocation 流程,包括权限持久化;当监视成功且不再出现错误消息,并且文档中说明的异步行为清晰时,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- android, typescript
- 领域
- mobile-dev
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 45/100