Files
inji-wallet/shared/location.ts
2022-09-16 14:45:58 +08:00

20 lines
590 B
TypeScript

import LocationEnabler from 'react-native-location-enabler';
const LOCATION_CONFIG = {
priority: LocationEnabler.PRIORITIES.BALANCED_POWER_ACCURACY,
alwaysShow: false,
needBle: true,
};
export function checkLocation(onEnabled: () => void, onDisabled: () => void) {
const subscription = LocationEnabler.addListener(({ locationEnabled }) => {
locationEnabled ? onEnabled() : onDisabled();
});
LocationEnabler.checkSettings(LOCATION_CONFIG);
return subscription;
}
export function requestLocation() {
return LocationEnabler.requestResolutionSettings(LOCATION_CONFIG);
}