This repository was archived by the owner on Nov 8, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 77
Implements #182 #183
Closed
Closed
Implements #182 #183
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
73c13c7
use tns-core-modules import path
bradmartin ca88e64
add isEnabledOptions interface
bradmartin e81ecef
implement isEnabledOptions for iOS
bradmartin 0d60502
change approach to match general Options interface
bradmartin 7ac20a2
update typing for isEnabled method
bradmartin e5cb9d7
change approach
bradmartin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import { Accuracy } from "tns-core-modules/ui/enums"; | ||
import { setTimeout, clearTimeout } from "timer"; | ||
import { on as applicationOn, uncaughtErrorEvent, UnhandledErrorEventData } from "application"; | ||
import { setTimeout, clearTimeout } from "tns-core-modules/timer"; | ||
import { on as applicationOn, uncaughtErrorEvent, UnhandledErrorEventData } from "tns-core-modules/application"; | ||
import * as utils from "tns-core-modules/utils/utils"; | ||
|
||
import { | ||
LocationBase, | ||
|
@@ -275,12 +276,28 @@ function _isEnabled(options?: Options): boolean { | |
return false; | ||
} | ||
|
||
export function isEnabled(): Promise<boolean> { | ||
export function isEnabled(options: Options): Promise<boolean> { | ||
return new Promise(function (resolve, reject) { | ||
resolve(_isEnabled()); | ||
const isEnabledResult = _isEnabled(); | ||
const status = CLLocationManager.authorizationStatus(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we could reuse the
|
||
// checking if the status for location has been denied previously | ||
// checking if the function has been provided the options and the `iosOpenSettingsIfLocationHasBeenDenied` value as true | ||
if (isEnabledResult === false && | ||
status === CLAuthorizationStatus.kCLAuthorizationStatusDenied && | ||
options && | ||
options.iosOpenSettingsIfLocationHasBeenDenied === true | ||
) { | ||
// now open the Settings so the user can toggle the Location permission | ||
utils.ios.getter(UIApplication, UIApplication.sharedApplication).openURL(NSURL.URLWithString(UIApplicationOpenSettingsURLString)); | ||
} | ||
resolve(isEnabledResult); | ||
}); | ||
} | ||
|
||
export function getIOSLocationManagerStatus(): CLAuthorizationStatus { | ||
return CLLocationManager.authorizationStatus(); | ||
} | ||
|
||
export function distance(loc1: Location, loc2: Location): number { | ||
if (!loc1.ios) { | ||
loc1.ios = clLocationFromLocation(loc1); | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
iosOpenSettingsIfLocationIsDisabled -> iosOpenSettingsIfLocationHasBeenDenied