NativeScript / NativeScript/plugins

[Android] [@nativescript/geolocation] Cannot watch location. Call "enableLocationRequest" first

Đang mở
#606 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Ngôn ngữ chính
TypeScript
Star
206
Fork
123
Merge trung bình
2 ngày 1 giờ
Pull request đã merge (30 ngày)
1

Mô tả

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.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu bằng cách tái hiện mẫu với @nativescript/geolocation 9.0.0 trên Android API 35, sau đó so sánh hành vi của nó với phiên bản 8.3.1. Kiểm tra luồng enableLocationRequest và watchLocation, bao gồm cả việc duy trì quyền; được xem là hoàn tất khi việc theo dõi thành công mà không xuất hiện thông báo sai và hành vi async được ghi trong tài liệu là rõ ràng.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
android, typescript
Lĩnh vực
mobile-dev
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
45/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.