T
Size: a a a
T
V
const getUserCoordinates = () => {
let res = null;
RNLocation.configure({
distanceFilter: 5.0
});
RNLocation.requestPermission({
ios: 'whenInUse',
android: {
detail: 'fine'
}
})
.then(granted => {
if (granted) {
RNLocation.subscribeToLocationUpdates(locations => {
res = {
lat: locations[0].latitude,
lon: locations[0].longitude,
};
setUserCoordinates(res);
});
} else {
setOrderType('rating');
}
})
.catch(() => {
setOrderType('rating');
});
return res;
};
NLocation.requestPermission
T
VP
return RNLocation.requestPermission
...
return RNLocation.subscribeToLocationUpdates
BS
AE
BS
AE
AE
BS
T
return RNLocation.requestPermission
...
return RNLocation.subscribeToLocationUpdates
BS
return RNLocation.requestPermission
...
return RNLocation.subscribeToLocationUpdates
VP
T
const getUserCoordinates = async () => {
let res = null;
RNLocation.configure({
distanceFilter: 5.0
});
const granted = await RNLocation.requestPermission({
ios: 'whenInUse',
android: {
detail: 'fine'
}
});
if (granted) {
return new Promise((resolve, reject) => {
RNLocation.subscribeToLocationUpdates(locations => {
res = {
lat: locations[0].latitude,
lon: locations[0].longitude,
};
setUserCoordinates(res);
if (!locations) {
return reject();
}
return resolve(res);
});
});
} else {
setOrderType('rating');
return null;
}
};
BS
const getUserCoordinates = async () => {
let res = null;
RNLocation.configure({
distanceFilter: 5.0
});
const granted = await RNLocation.requestPermission({
ios: 'whenInUse',
android: {
detail: 'fine'
}
});
if (granted) {
return new Promise((resolve, reject) => {
RNLocation.subscribeToLocationUpdates(locations => {
res = {
lat: locations[0].latitude,
lon: locations[0].longitude,
};
setUserCoordinates(res);
if (!locations) {
return reject();
}
return resolve(res);
});
});
} else {
setOrderType('rating');
return null;
}
};
T
BS
T
VP
АГ