Разрешение цепи Android для Bluetooth, местоположения, фонаAndroid

Форум для тех, кто программирует под Android
Ответить
Гость
 Разрешение цепи Android для Bluetooth, местоположения, фона

Сообщение Гость »


I'm trying to chain my Android permissions. What I'm attempting to achieve is to check if the permissions are granted when the user focuses on a specific screen. First, by checking my Bluetooth; if it's false, then a Bluetooth modal will pop up with two options: cancel (to navigate back) and grant (to give permission). After that, I need to check the fine and coarse location permissions (same logic as the Bluetooth modal). Finally, I need to check the background permissions.

My current problem is that the location modal pops up before the Bluetooth modal, and the background permission modal doesn't appear at all.
useFocusEffect( useCallback(() => { PermissionsAndroid.check( PermissionsAndroid.PERMISSIONS.BLUETOOTH_CONNECT ).then((res) => { console.log({ res }); if (!res) { setBluetoothModal(true); } PermissionsAndroid.check( PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION ).then((res) => { res ? PermissionsAndroid.check( PermissionsAndroid.PERMISSIONS.ACCESS_COARSE_LOCATION ).then((res) => { res ? PermissionsAndroid.check( PermissionsAndroid.PERMISSIONS.ACCESS_BACKGROUND_LOCATION ).then((res) => { if (!res) { PermissionsAndroid.request( PermissionsAndroid.PERMISSIONS .ACCESS_BACKGROUND_LOCATION, { title: "Background Location Access", message: `Darefore app collects location data in the background to record a session with GPS tracking on the phone. To record a session with GPS tracking, go to phone's Location permission and choose "Allow all the time".`, buttonNegative: "Cancel", buttonPositive: "OK", } ); } }) : setLocationModal(true); }) : setLocationModal(true); }); }); return () => {}; }, []) );

Источник: https://stackoverflow.com/questions/781 ... background
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Android»