nativescript-community / nativescript-community/ble
(Android) enableGPS does not attempt to enable GPS due to incorrect isGPSEnabled check
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
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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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