fix(inji-522): enable the location service before initiating the vc sharing. (#1004)

* fix(inji-522): enable the location service before initiating the vc sharing.

Signed-off-by: Vijay <94220135+vijay151096@users.noreply.github.com>

* fix(inji-522): update literals in the location service enabling popup

Signed-off-by: Vijay <94220135+vijay151096@users.noreply.github.com>

* fix(inji-522): update checkLocation state name

Signed-off-by: Vijay <94220135+vijay151096@users.noreply.github.com>

* fix(inji-522): removed duplicate namespace

Signed-off-by: Vijay <94220135+vijay151096@users.noreply.github.com>

---------

Signed-off-by: Vijay <94220135+vijay151096@users.noreply.github.com>
This commit is contained in:
vijay151096
2023-11-16 10:28:12 +05:30
committed by GitHub
parent a557b679ea
commit b0ebef0acd
14 changed files with 104 additions and 271 deletions

View File

@@ -1,12 +1,10 @@
plugins {
plugins {
id 'com.gladed.androidgitversion' version '0.4.14'
}
apply plugin: "com.android.application"
apply plugin: "com.facebook.react"
import com.android.build.OutputFile
react {
/* Folders */
// The root of your project, i.e. where "package.json" lives. Default is '..'
@@ -102,9 +100,6 @@ android {
}
namespace 'io.mosip.residentapp'
namespace 'io.mosip.residentapp'
defaultConfig {
@@ -130,7 +125,7 @@ android {
include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
}
}
signingConfigs {
release {
def keystore = file('release.keystore')
@@ -232,7 +227,7 @@ dependencies {
implementation 'com.facebook.fresco:animated-webp:2.0.0'
}
}
compileOnly project(':react-native-android-location-services-dialog-box')
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}")
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
@@ -252,4 +247,4 @@ dependencies {
}
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
apply from: "./eas-build.gradle"
apply from: "./eas-build.gradle"

View File

@@ -3,6 +3,7 @@ rootProject.name = 'Inji'
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
include ':app'
includeBuild('../node_modules/react-native-gradle-plugin')
include ':react-native-android-location-services-dialog-box'
project(':react-native-android-location-services-dialog-box').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-android-location-services-dialog-box/android')
apply from: new File(["node", "--print", "require.resolve('expo/package.json')"].execute(null, rootDir).text.trim(), "../scripts/autolinking.gradle")
useExpoModules()
useExpoModules()

View File

@@ -478,7 +478,7 @@
"sharingVc": "مشاركة بطاقة ",
"errors": {
"locationDisabled": {
"message": "يجب تمكين خدمات الموقع لمشاركة البطاقة",
"message": "للمتابعة، اسمح لجهازك بتشغيل الموقع",
"button": "تمكين خدمات الموقع"
},
"locationDenied": {
@@ -593,6 +593,7 @@
"cancel": "إلغاء",
"accept": "يقبل",
"save": "حفظ",
"ok": "نعم",
"dismiss": "رفض",
"editLabel": "يحرر {{label}}",
"tryAgain": "حاول مجددا",

View File

@@ -479,7 +479,7 @@
"scanningGuide": "Hold the phone steady and scan the QR code",
"errors": {
"locationDisabled": {
"message": "Location services must be enabled to share card",
"message": "To continue, let your device turn on location",
"button": "Enable location services"
},
"locationDenied": {

View File

@@ -481,7 +481,7 @@
"scanningGuide": "Panatilihin ang telepono at i-scan ang QR code",
"errors": {
"locationDisabled": {
"message": "Dapat na nakabukas ang Location services ng iyong mobile para maaaring makapag-scan",
"message": "Para magpatuloy, hayaang i-on ng iyong device ang lokasyon",
"button": "Buksan ang location services"
},
"locationDenied": {
@@ -596,6 +596,7 @@
"cancel": "Kanselahin",
"accept": "Tanggapin",
"save": "I-save",
"ok": "Ok",
"dismiss": "Dismissed",
"editLabel": "Palitan ang {{label}}",
"tryAgain": "Subukan muli",

View File

@@ -478,7 +478,7 @@
"scanningGuide": "फ़ोन को स्थिर रखें और QR कोड को स्कैन करें",
"errors": {
"locationDisabled": {
"message": "स्थान सेवाओं को स्कैनिंग कार्यक्षमता के लिए सक्षम किया जाना चाहिए",
"message": "जारी रखने के लिए, अपने डिवाइस को स्थान चालू करने दें",
"button": "स्थान सेवाएं सक्षम करें"
},
"locationDenied": {
@@ -592,6 +592,7 @@
"common": {
"cancel": "रद्द करें",
"save": "सहेजें",
"ok": "ठीक है",
"dismiss": "नकार देना",
"editLabel": "संपादित करें {{label}}",
"tryAgain": "पुनः प्रयास करें",

View File

@@ -476,7 +476,7 @@
"scanningGuide": "ಫೋನ್ ಅನ್ನು ಸ್ಥಿರವಾಗಿ ಹಿಡಿದುಕೊಳ್ಳಿ ಮತ್ತು QR ಕೋಡ್ ಅನ್ನು ಸ್ಕ್ಯಾನ್ ಮಾಡಿ",
"errors": {
"locationDisabled": {
"message": "ಸ್ಕ್ಯಾನಿಂಗ್ ಕಾರ್ಯಕ್ಕಾಗಿ ಸ್ಥಳ ಸೇವೆಗಳನ್ನು ಸಕ್ರಿಯಗೊಳಿಸಬೇಕು",
"message": "ಮುಂದುವರಿಸಲು, ನಿಮ್ಮ ಸಾಧನವು ಸ್ಥಳವನ್ನು ಆನ್ ಮಾಡಲು ಅನುಮತಿಸಿ",
"button": "ಸ್ಥಳ ಸೇವೆಗಳನ್ನು ಸಕ್ರಿಯಗೊಳಿಸಿ"
},
"locationDenied": {
@@ -591,6 +591,7 @@
"cancel": "ರದ್ದು",
"accept": "ಒಪ್ಪಿಕೊಳ್ಳಿ",
"save": "ಉಳಿಸು",
"ok": "ಸರಿ",
"dismiss": "ವಜಾಗೊಳಿಸಿ",
"editLabel": "ಸಂಪಾದಿಸು {{label}}",
"tryAgain": "ಮತ್ತೆ ಪ್ರಯತ್ನಿಸು",

View File

@@ -412,7 +412,7 @@
"enableBluetoothButtonText": "Permitir permisos de Bluetooth",
"errors": {
"locationDisabled": {
"message": "Los servicios de ubicación deben estar habilitados para compartir la tarjeta",
"message": "Para continuar, deja que tu dispositivo active la ubicación.",
"button": "Habilitar servicios de ubicación"
},
"locationDenied": {
@@ -501,6 +501,7 @@
"common": {
"cancel": "Cancelar",
"save": "Guardar",
"ok": "Ok",
"dismiss": "Cerrar",
"editLabel": "Editar {{label}}",
"tryAgain": "Intentar de nuevo",

View File

@@ -476,7 +476,7 @@
"scanningGuide": "ஃபோனை நிலையாகப் பிடித்து, QR குறியீட்டை ஸ்கேன் செய்யவும்s",
"errors": {
"locationDisabled": {
"message": "ஸ்கேனிங் செயல்பாட்டிற்கு இருப்பிடச் சேவைகள் இயக்கப்பட வேண்டும்",
"message": "தொடர, இருப்பிடத்தை இயக்க உங்கள் சாதனத்தை அனுமதிக்கவும்",
"button": "இருப்பிட சேவைகளை இயக்கு"
},
"locationDenied": {
@@ -591,6 +591,7 @@
"cancel": "ரத்துசெய்",
"accept": "ஏற்றுக்கொள்",
"save": "சேமி",
"ok": "சரி",
"dismiss": "நிராகரி",
"editLabel": "திருத்து {{label}}",
"tryAgain": "மீண்டும் முயற்சி செய்",

View File

@@ -22,13 +22,14 @@ import {subscribe} from '../../../shared/openIdBLE/walletEventHandler';
import {
check,
checkMultiple,
PermissionStatus,
PERMISSIONS,
PermissionStatus,
requestMultiple,
RESULTS,
} from 'react-native-permissions';
import {
checkLocationPermissionStatus,
checkLocationService,
requestLocationPermission,
} from '../../../shared/location';
import {CameraCapturedPicture} from 'expo-camera';
@@ -40,14 +41,14 @@ import {BLEError} from '../types';
import Storage from '../../../shared/storage';
import {VCMetadata} from '../../../shared/VCMetadata';
import {
getStartEventData,
getEndEventData,
sendStartEvent,
sendEndEvent,
sendImpressionEvent,
getImpressionEventData,
sendErrorEvent,
getErrorEventData,
getImpressionEventData,
getStartEventData,
sendEndEvent,
sendErrorEvent,
sendImpressionEvent,
sendStartEvent,
} from '../../../shared/telemetry/TelemetryUtils';
import {TelemetryConstants} from '../../../shared/telemetry/TelemetryConstants';
@@ -307,7 +308,7 @@ export const scanMachine =
always: [
{
cond: 'uptoAndroid11',
target: '#scan.checkingLocationService',
target: '#scan.checkingLocationState',
},
{
target: '#scan.clearingConnection',
@@ -337,7 +338,7 @@ export const scanMachine =
always: [
{
cond: 'uptoAndroid11',
target: '#scan.checkingLocationService',
target: '#scan.checkingLocationState',
},
{
target: '#scan.clearingConnection',
@@ -678,9 +679,22 @@ export const scanMachine =
},
},
},
checkingLocationService: {
initial: 'checkingPermissionStatus',
checkingLocationState: {
initial: 'checkLocationService',
states: {
checkLocationService: {
invoke: {
src: 'checkLocationStatus',
},
on: {
LOCATION_ENABLED: {
target: 'checkingPermissionStatus',
},
LOCATION_DISABLED: {
target: 'disabled',
},
},
},
checkingPermissionStatus: {
invoke: {
src: 'checkLocationPermission',
@@ -717,6 +731,13 @@ export const scanMachine =
},
},
},
disabled: {
on: {
LOCATION_REQUEST: {
target: 'checkLocationService',
},
},
},
},
},
},
@@ -1096,6 +1117,12 @@ export const scanMachine =
() => callback(model.events.LOCATION_DISABLED()),
);
},
checkLocationStatus: () => callback => {
return checkLocationService(
() => callback(model.events.LOCATION_ENABLED()),
() => callback(model.events.LOCATION_DISABLED()),
);
},
startConnection: context => callback => {
wallet.startConnection(context.openId4VpUri);

View File

@@ -1,236 +0,0 @@
// This file was automatically generated. Edits will be overwritten
export interface Typegen0 {
'@@xstate/typegen': true;
internalEvents: {
'': {type: ''};
'done.invoke.QrLogin': {
type: 'done.invoke.QrLogin';
data: unknown;
__tip: 'See the XState TS docs to learn how to strongly type this.';
};
'done.invoke.scan.checkStorage:invocation[0]': {
type: 'done.invoke.scan.checkStorage:invocation[0]';
data: unknown;
__tip: 'See the XState TS docs to learn how to strongly type this.';
};
'done.invoke.scan.reviewing.creatingVp:invocation[0]': {
type: 'done.invoke.scan.reviewing.creatingVp:invocation[0]';
data: unknown;
__tip: 'See the XState TS docs to learn how to strongly type this.';
};
'xstate.after(CONNECTION_TIMEOUT)#scan.connecting.inProgress': {
type: 'xstate.after(CONNECTION_TIMEOUT)#scan.connecting.inProgress';
};
'xstate.after(DESTROY_TIMEOUT)#scan.clearingConnection': {
type: 'xstate.after(DESTROY_TIMEOUT)#scan.clearingConnection';
};
'xstate.after(SHARING_TIMEOUT)#scan.reviewing.sendingVc.inProgress': {
type: 'xstate.after(SHARING_TIMEOUT)#scan.reviewing.sendingVc.inProgress';
};
'xstate.init': {type: 'xstate.init'};
'xstate.stop': {type: 'xstate.stop'};
};
invokeSrcNameMap: {
checkBluetoothPermission: 'done.invoke.scan.checkBluetoothPermission.checking:invocation[0]';
checkBluetoothState:
| 'done.invoke.scan.checkBluetoothState.checking:invocation[0]'
| 'done.invoke.scan.recheckBluetoothState.checking:invocation[0]';
checkLocationPermission: 'done.invoke.scan.checkingLocationService.checkingPermissionStatus:invocation[0]';
checkNearByDevicesPermission: 'done.invoke.scan.checkNearbyDevicesPermission.checking:invocation[0]';
checkStorageAvailability: 'done.invoke.scan.checkStorage:invocation[0]';
createVp: 'done.invoke.scan.reviewing.creatingVp:invocation[0]';
disconnect:
| 'done.invoke.scan.clearingConnection:invocation[0]'
| 'done.invoke.scan.disconnectDevice:invocation[0]';
monitorConnection: 'done.invoke.scan:invocation[0]';
requestBluetooth: 'done.invoke.scan.checkBluetoothState.requesting:invocation[0]';
requestNearByDevicesPermission: 'done.invoke.scan.checkNearbyDevicesPermission.requesting:invocation[0]';
requestToEnableLocationPermission: 'done.invoke.scan.checkingLocationService.requestToEnableLocation:invocation[0]';
sendVc: 'done.invoke.scan.reviewing.sendingVc:invocation[0]';
startConnection: 'done.invoke.scan.connecting:invocation[0]';
};
missingImplementations: {
actions: never;
delays: never;
guards: never;
services: never;
};
eventsCausingActions: {
clearCreatedVp:
| ''
| 'BLE_ERROR'
| 'DISCONNECT'
| 'DISMISS'
| 'RESET'
| 'SCREEN_BLUR'
| 'SCREEN_FOCUS'
| 'xstate.stop';
clearReason:
| ''
| 'BLE_ERROR'
| 'DISCONNECT'
| 'DISMISS'
| 'RESET'
| 'SCREEN_BLUR'
| 'SCREEN_FOCUS'
| 'xstate.stop';
clearUri:
| 'DISCONNECT'
| 'DISMISS'
| 'xstate.after(DESTROY_TIMEOUT)#scan.clearingConnection';
logFailedVerification: 'FACE_INVALID';
logShared: 'VC_ACCEPTED';
openAppPermission: 'GOTO_SETTINGS' | 'LOCATION_REQUEST';
openBluetoothSettings: 'GOTO_SETTINGS';
registerLoggers:
| 'DISCONNECT'
| 'DISMISS'
| 'xstate.after(DESTROY_TIMEOUT)#scan.clearingConnection';
removeLoggers:
| 'DISCONNECT'
| 'DISMISS'
| 'SCREEN_BLUR'
| 'xstate.after(DESTROY_TIMEOUT)#scan.clearingConnection'
| 'xstate.init';
resetShouldVerifyPresence: 'CANCEL' | 'CONNECTED' | 'DISMISS' | 'RETRY';
sendScanData: 'SCAN';
setBleError: 'BLE_ERROR';
setChildRef:
| 'DISCONNECT'
| 'DISMISS'
| 'xstate.after(DESTROY_TIMEOUT)#scan.clearingConnection';
setCreatedVp: 'done.invoke.scan.reviewing.creatingVp:invocation[0]';
setLinkCode: 'SCAN';
setPromptHint: 'CANCEL' | 'RETRY';
setReadyForBluetoothStateCheck: 'BLUETOOTH_PERMISSION_ENABLED';
setReason: 'UPDATE_REASON';
setReceiverInfo: 'CONNECTED';
setSelectedVc: 'SELECT_VC';
setSenderInfo: 'CONNECTED';
setShareLogTypeUnverified: 'ACCEPT_REQUEST';
setShareLogTypeVerified: 'FACE_VALID';
setStayInProgress:
| 'STAY_IN_PROGRESS'
| 'xstate.after(CONNECTION_TIMEOUT)#scan.connecting.inProgress'
| 'xstate.after(SHARING_TIMEOUT)#scan.reviewing.sendingVc.inProgress';
setUri: 'SCAN';
storeLoginItem: 'done.invoke.QrLogin';
storingActivityLog: 'STORE_RESPONSE';
toggleShouldVerifyPresence: 'TOGGLE_USER_CONSENT';
};
eventsCausingDelays: {
CONNECTION_TIMEOUT: 'SCAN';
DESTROY_TIMEOUT: '' | 'DISMISS' | 'LOCATION_ENABLED';
SHARING_TIMEOUT:
| 'ACCEPT_REQUEST'
| 'FACE_VALID'
| 'done.invoke.scan.reviewing.creatingVp:invocation[0]';
};
eventsCausingGuards: {
isIOS: 'BLUETOOTH_STATE_DISABLED' | 'START_PERMISSION_CHECK';
isMinimumStorageRequiredForAuditEntryReached: 'done.invoke.scan.checkStorage:invocation[0]';
isOpenIdQr: 'SCAN';
isQrLogin: 'SCAN';
uptoAndroid11: '' | 'START_PERMISSION_CHECK';
};
eventsCausingServices: {
QrLogin: 'SCAN';
checkBluetoothPermission:
| ''
| 'BLUETOOTH_STATE_DISABLED'
| 'NEARBY_ENABLED'
| 'START_PERMISSION_CHECK';
checkBluetoothState: '' | 'APP_ACTIVE';
checkLocationPermission: '' | 'APP_ACTIVE';
checkNearByDevicesPermission: 'APP_ACTIVE' | 'START_PERMISSION_CHECK';
checkStorageAvailability: 'RESET' | 'SCREEN_FOCUS';
createVp: never;
disconnect: '' | 'DISMISS' | 'LOCATION_ENABLED' | 'SCREEN_BLUR';
monitorConnection: 'DISMISS' | 'SCREEN_BLUR' | 'xstate.init';
requestBluetooth: 'BLUETOOTH_STATE_DISABLED';
requestNearByDevicesPermission: 'NEARBY_DISABLED';
requestToEnableLocationPermission: 'LOCATION_DISABLED';
sendVc:
| 'ACCEPT_REQUEST'
| 'FACE_VALID'
| 'done.invoke.scan.reviewing.creatingVp:invocation[0]';
startConnection: 'SCAN';
};
matchesStates:
| 'bluetoothDenied'
| 'bluetoothPermissionDenied'
| 'checkBluetoothPermission'
| 'checkBluetoothPermission.checking'
| 'checkBluetoothPermission.enabled'
| 'checkBluetoothState'
| 'checkBluetoothState.checking'
| 'checkBluetoothState.enabled'
| 'checkBluetoothState.requesting'
| 'checkNearbyDevicesPermission'
| 'checkNearbyDevicesPermission.checking'
| 'checkNearbyDevicesPermission.enabled'
| 'checkNearbyDevicesPermission.requesting'
| 'checkStorage'
| 'checkingLocationService'
| 'checkingLocationService.checkingPermissionStatus'
| 'checkingLocationService.denied'
| 'checkingLocationService.requestToEnableLocation'
| 'clearingConnection'
| 'connecting'
| 'connecting.inProgress'
| 'connecting.timeout'
| 'disconnectDevice'
| 'disconnected'
| 'findingConnection'
| 'handlingBleError'
| 'inactive'
| 'invalid'
| 'nearByDevicesPermissionDenied'
| 'recheckBluetoothState'
| 'recheckBluetoothState.checking'
| 'recheckBluetoothState.enabled'
| 'restrictSharingVc'
| 'reviewing'
| 'reviewing.accepted'
| 'reviewing.cancelling'
| 'reviewing.creatingVp'
| 'reviewing.invalidIdentity'
| 'reviewing.navigatingToHome'
| 'reviewing.rejected'
| 'reviewing.selectingVc'
| 'reviewing.sendingVc'
| 'reviewing.sendingVc.inProgress'
| 'reviewing.sendingVc.sent'
| 'reviewing.sendingVc.timeout'
| 'reviewing.verifyingIdentity'
| 'showQrLogin'
| 'showQrLogin.idle'
| 'showQrLogin.navigatingToHistory'
| 'showQrLogin.storing'
| 'startPermissionCheck'
| {
checkBluetoothPermission?: 'checking' | 'enabled';
checkBluetoothState?: 'checking' | 'enabled' | 'requesting';
checkNearbyDevicesPermission?: 'checking' | 'enabled' | 'requesting';
checkingLocationService?:
| 'checkingPermissionStatus'
| 'denied'
| 'requestToEnableLocation';
connecting?: 'inProgress' | 'timeout';
recheckBluetoothState?: 'checking' | 'enabled';
reviewing?:
| 'accepted'
| 'cancelling'
| 'creatingVp'
| 'invalidIdentity'
| 'navigatingToHome'
| 'rejected'
| 'selectingVc'
| 'sendingVc'
| 'verifyingIdentity'
| {sendingVc?: 'inProgress' | 'sent' | 'timeout'};
showQrLogin?: 'idle' | 'navigatingToHistory' | 'storing';
};
tags: never;
}

15
package-lock.json generated
View File

@@ -48,6 +48,7 @@
"react": "18.2.0",
"react-i18next": "^11.16.6",
"react-native": "0.71.8",
"react-native-android-location-services-dialog-box": "^2.8.2",
"react-native-app-auth": "^7.0.0",
"react-native-app-intro-slider": "^4.0.4",
"react-native-argon2": "^2.0.1",
@@ -25761,6 +25762,14 @@
"react": "18.2.0"
}
},
"node_modules/react-native-android-location-services-dialog-box": {
"version": "2.8.2",
"resolved": "https://registry.npmjs.org/react-native-android-location-services-dialog-box/-/react-native-android-location-services-dialog-box-2.8.2.tgz",
"integrity": "sha512-zBTi0xJQoF6GdImRhXOCXezYuALlPgbctqG3eOrZu63hdrlvTBhqATkb6DB5JM9kpcMbX1skMIOI3m71zKGsPA==",
"peerDependencies": {
"react-native": ">= 0.56.0"
}
},
"node_modules/react-native-app-auth": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/react-native-app-auth/-/react-native-app-auth-7.0.0.tgz",
@@ -49740,6 +49749,12 @@
}
}
},
"react-native-android-location-services-dialog-box": {
"version": "2.8.2",
"resolved": "https://registry.npmjs.org/react-native-android-location-services-dialog-box/-/react-native-android-location-services-dialog-box-2.8.2.tgz",
"integrity": "sha512-zBTi0xJQoF6GdImRhXOCXezYuALlPgbctqG3eOrZu63hdrlvTBhqATkb6DB5JM9kpcMbX1skMIOI3m71zKGsPA==",
"requires": {}
},
"react-native-app-auth": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/react-native-app-auth/-/react-native-app-auth-7.0.0.tgz",

View File

@@ -50,6 +50,7 @@
"react": "18.2.0",
"react-i18next": "^11.16.6",
"react-native": "0.71.8",
"react-native-android-location-services-dialog-box": "^2.8.2",
"react-native-app-auth": "^7.0.0",
"react-native-app-intro-slider": "^4.0.4",
"react-native-argon2": "^2.0.1",
@@ -82,7 +83,7 @@
"react-native-vector-icons": "^10.0.0",
"short-unique-id": "^4.4.4",
"simple-pem2jwk": "^0.2.4",
"telemetry-sdk": "git://github.com/mosip/sunbird-telemetry-sdk.git#f762be5732ee552c0c70bdd540aa4e2701554c71",
"telemetry-sdk": "git://github.com/mosip/sunbird-telemetry-sdk.git#f762be5732ee552c0c70bdd540aa4e2701554c71",
"xstate": "^4.35.0"
},
"devDependencies": {

View File

@@ -1,5 +1,6 @@
import RNLocation from 'react-native-location';
import LocationServicesDialogBox from 'react-native-android-location-services-dialog-box';
import i18n from '../i18n';
// Initialize RNLocation
RNLocation.configure({
distanceFilter: 5.0, // Example configuration, adjust as needed
@@ -7,26 +8,26 @@ RNLocation.configure({
export function checkLocationPermissionStatus(
onEnabled: () => void,
onDisabled: () => void
onDisabled: () => void,
) {
RNLocation.checkPermission({
android: {
detail: 'fine',
},
})
.then((granted) => {
.then(granted => {
if (granted) {
return onEnabled();
} else {
return onDisabled();
}
})
.catch((err) => console.log('Error getting location:', err));
.catch(err => console.log('Error getting location:', err));
}
export async function requestLocationPermission(
onEnabled: () => void,
onDisabled: () => void
onDisabled: () => void,
) {
try {
const granted = await RNLocation.requestPermission({
@@ -43,3 +44,26 @@ export async function requestLocationPermission(
console.log(error);
}
}
export async function checkLocationService(
onEnabled: () => void,
onDisabled: () => void,
) {
try {
const config = {
message: i18n.t('ScanScreen:errors:locationDisabled:message'),
ok: i18n.t('common:ok'),
cancel: i18n.t('common:dismiss'),
enableHighAccuracy: true, // true => GPS AND NETWORK PROVIDER, false => GPS OR NETWORK PROVIDER
showDialog: true, // false => Opens the Location access page directly
openLocationServices: true, // false => Directly catch method is called if location services are turned off
preventOutSideTouch: false, //true => To prevent the location services popup from closing when it is clicked outside
preventBackClick: false, //true => To prevent the location services popup from closing when it is clicked back button
providerListener: true, // true ==> Trigger "locationProviderStatusChange" listener when the location state changes
};
await LocationServicesDialogBox.checkLocationServicesIsEnabled(config);
onEnabled();
} catch (e) {
onDisabled();
}
}