mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-21 00:52:55 +00:00
@@ -13,7 +13,6 @@
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {Injectable} from '@angular/core';
|
||||
import {Geolocation} from '@ionic-native/geolocation/ngx';
|
||||
import {
|
||||
SCSetting,
|
||||
SCSettingValue,
|
||||
@@ -196,11 +195,9 @@ export class SettingsProvider {
|
||||
*
|
||||
* @param storage TODO
|
||||
* @param configProvider TODO
|
||||
* @param geoLocation TODO
|
||||
*/
|
||||
constructor(private readonly storage: StorageProvider,
|
||||
private readonly configProvider: ConfigProvider,
|
||||
private readonly geoLocation: Geolocation) {
|
||||
private readonly configProvider: ConfigProvider) {
|
||||
this.categoriesOrder = [];
|
||||
this.settingsCache = {};
|
||||
}
|
||||
@@ -265,32 +262,6 @@ export class SettingsProvider {
|
||||
return this.settingsCache[category] !== undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for user permission to use location
|
||||
*/
|
||||
public async checkGeoLocationPermission(): Promise<boolean> {
|
||||
// request geoLocation to test the user permission
|
||||
try {
|
||||
// set enableHighAccuracy, otherwise android platform does not respond
|
||||
const options = {
|
||||
enableHighAccuracy: true,
|
||||
};
|
||||
await this.geoLocation.getCurrentPosition(options);
|
||||
} catch (error) {
|
||||
// if error code is 1 the user denied permission,
|
||||
// other errors like 'timeout' or 'no location' will be ignored here
|
||||
if (error.code === 1) {
|
||||
// ios has special error message for disabled location services, for the setting we ignore it
|
||||
if (error.message.toLowerCase() !== 'location services are disabled.') {
|
||||
// revert setting value
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns copy of cached settings
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user