nativescript-community / nativescript-community/ble

(Android) enableGPS does not attempt to enable GPS due to incorrect isGPSEnabled check

Open
#266 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
202
Forks
79
PR merge metrics
No merged PRs in 30d

Description

enableGPS uses the check

if (!this.isGPSEnabled())

to determine whether we need to prompt the user to enable location services on the device. isGPSEnabled however returns a Promise, meaning the non-awaited returned value is always truthy, and therefore enableGPS will never actually actually prompt the user to enable location services, even if the promise returned by isGPSEnabled resolves to false

https://github.com/nativescript-community/ble/blob/9820235506bea2bd27e82bc994cc512f6821b859/src/ble/index.android.ts#L1277-L1300

A simple solution would be to make the promise constructor callback async and adjust the condition to:

if (!(await this.isGPSEnabled()))

The check after receiving the request result from the system on line 1287 also needs to be corrected
https://github.com/nativescript-community/ble/blob/9820235506bea2bd27e82bc994cc512f6821b859/src/ble/index.android.ts#L1287

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/ble/index.android.ts around lines 1277-1300 and trace both isGPSEnabled checks in enableGPS. Confirm that the asynchronous checks use the resolved boolean, including the check after the system request result, and that enableGPS prompts when location services are disabled.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, typescript
Domain
mobile
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.