Я вставляю карту в свое приложение. Я использовал реагирующие карты, и это делает прекрасно. Тем не менее, я совершенно не могу получить разрешения на местонахождение для работы. Я не уверен почему. "iosPermissions": [
"Camera",
"Microphone",
"LocationAlways",
"LocationWhenInUse"
]
}```
< /code>
Из моего компонента запроса на разрешение (я знаю, что это довольно неряшливо, я просто пытаюсь убедиться, что он работает до того, как я его очистил): < /p>
export function RequestPermissions(permission_number: number) {
let permissionText: number = 0;
RNPermissions.request(PERMISSIONS.IOS.LOCATION_WHEN_IN_USE).then((status) => {
switch (status) {
case RESULTS.UNAVAILABLE:
console.log('This feature is not available (on this device / in this context)');
//really i should return a number here to indicate the permission status so that the next step
permissionText =1;
return permissionText;
case RESULTS.DENIED:
console.log('The permission has not been requested / is denied but requestable');
permissionText = 2;
return permissionText;
case RESULTS.BLOCKED:
permissionText =3;
console.log('The permission is denied and not requestable');
return permissionText;
case RESULTS.GRANTED:
console.log('The permission is granted');
permissionText =4;
return permissionText;
case RESULTS.LIMITED:
console.log('The permission is granted but with limitations');
permissionText =5;
return permissionText;
}
});
return permissionText;
}
< /code>
и, наконец, когда я звоню < /p>
import { View, StyleSheet, Text } from 'react-native';
import MapView from 'react-native-maps';
import { RequestPermissions, CheckPermissions } from '@/components/TryPermissions';
import * as Location from "expo-location";
import { PermissionStatus } from 'expo-location';
const MapScreen: React.FC = () => {
return (
);
};
const ReadyMap: React.FC = () => {
const [hasPermission, setHasPermission] = useState(null);
let checkpermssionrequestex: number = 0;
useEffect(() => {
const checkAndRequestPermissions = async () => {
let permissionStatus = await CheckPermissions(1); // Check for location permission
if (permissionStatus !== 4) {
permissionStatus = await RequestPermissions(1); // Request location permission
checkpermssionrequestex = permissionStatus;
}
setHasPermission(permissionStatus === 4);
};
checkAndRequestPermissions();
}, []);
if (hasPermission === null) {
return Loading...; // Show a loading state while checking permissions
}
if (!hasPermission) {
console.log(PermissionStatus);
alert("permssion request returned negative, loading map with default location");
return ;
}
return ; // Render the map if permission is granted
};
const styles = StyleSheet.create({
container: {
flex: 1,
},
map: {
flex: 1,
},
});
export default ReadyMap;
Note: This will render map, but instead of asking for permission it jumps straight to permission denied. I am running a developer build on an actual device. I am assuming there is a problem with my code and thus, haven't included all the specs, but can provide more info if necessary.
As always, I appreciate any assistance.
Подробнее здесь: https://stackoverflow.com/questions/796 ... permission
Реактивные промезания для iOS никогда не просит разрешения ⇐ IOS
Программируем под IOS
-
Anonymous
1746229623
Anonymous
Я вставляю карту в свое приложение. Я использовал реагирующие карты, и это делает прекрасно. Тем не менее, я совершенно не могу получить разрешения на местонахождение для работы. Я не уверен почему. "iosPermissions": [
"Camera",
"Microphone",
"LocationAlways",
"LocationWhenInUse"
]
}```
< /code>
Из моего компонента запроса на разрешение (я знаю, что это довольно неряшливо, я просто пытаюсь убедиться, что он работает до того, как я его очистил): < /p>
export function RequestPermissions(permission_number: number) {
let permissionText: number = 0;
RNPermissions.request(PERMISSIONS.IOS.LOCATION_WHEN_IN_USE).then((status) => {
switch (status) {
case RESULTS.UNAVAILABLE:
console.log('This feature is not available (on this device / in this context)');
//really i should return a number here to indicate the permission status so that the next step
permissionText =1;
return permissionText;
case RESULTS.DENIED:
console.log('The permission has not been requested / is denied but requestable');
permissionText = 2;
return permissionText;
case RESULTS.BLOCKED:
permissionText =3;
console.log('The permission is denied and not requestable');
return permissionText;
case RESULTS.GRANTED:
console.log('The permission is granted');
permissionText =4;
return permissionText;
case RESULTS.LIMITED:
console.log('The permission is granted but with limitations');
permissionText =5;
return permissionText;
}
});
return permissionText;
}
< /code>
и, наконец, когда я звоню < /p>
import { View, StyleSheet, Text } from 'react-native';
import MapView from 'react-native-maps';
import { RequestPermissions, CheckPermissions } from '@/components/TryPermissions';
import * as Location from "expo-location";
import { PermissionStatus } from 'expo-location';
const MapScreen: React.FC = () => {
return (
);
};
const ReadyMap: React.FC = () => {
const [hasPermission, setHasPermission] = useState(null);
let checkpermssionrequestex: number = 0;
useEffect(() => {
const checkAndRequestPermissions = async () => {
let permissionStatus = await CheckPermissions(1); // Check for location permission
if (permissionStatus !== 4) {
permissionStatus = await RequestPermissions(1); // Request location permission
checkpermssionrequestex = permissionStatus;
}
setHasPermission(permissionStatus === 4);
};
checkAndRequestPermissions();
}, []);
if (hasPermission === null) {
return Loading...; // Show a loading state while checking permissions
}
if (!hasPermission) {
console.log(PermissionStatus);
alert("permssion request returned negative, loading map with default location");
return ;
}
return ; // Render the map if permission is granted
};
const styles = StyleSheet.create({
container: {
flex: 1,
},
map: {
flex: 1,
},
});
export default ReadyMap;
Note: This will render map, but instead of asking for permission it jumps straight to permission denied. I am running a developer build on an actual device. I am assuming there is a problem with my code and thus, haven't included all the specs, but can provide more info if necessary.
As always, I appreciate any assistance.
Подробнее здесь: [url]https://stackoverflow.com/questions/79604244/react-native-permissions-for-ios-never-asks-for-permission[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия