From 5e82e9c23eda7caa08ae13405048c545431d2341 Mon Sep 17 00:00:00 2001 From: Samuel Kim Date: Mon, 21 Mar 2022 18:17:50 +0900 Subject: [PATCH] Fix android bluetooth permission error --- android/app/build.gradle | 4 ++-- android/app/src/main/AndroidManifest.xml | 13 +++++++++++++ ios/TerraStation.xcodeproj/project.pbxproj | 8 ++++---- ios/TerraStation/Info.plist | 6 +++--- src/components/Error.tsx | 6 +++++- src/screens/auth/AuthMenu.tsx | 13 ++++++++++++- src/utils/permission.ts | 8 ++++++++ 7 files changed, 47 insertions(+), 11 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index c8e08b0b..55da7f3a 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -145,8 +145,8 @@ android { applicationId "money.terra.station" minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion - versionCode 10503003 - versionName "1.5.3" + versionCode 10504000 + versionName "1.5.4" multiDexEnabled true setProperty('archivesBaseName', renameArtifact('station-mobile', versionCode)) missingDimensionStrategy 'react-native-camera', 'general' diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index b8215c2e..5936ef2d 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -6,6 +6,19 @@ + + + + + + + + + + + NSBluetoothAlwaysUsageDescription - Connect with Ledger - NSBluetoothPeripheralUsageDescription - Connect with Ledger + Allow Bluetooth to connect with Ledger + NSBluetoothPeripheralUsageDescription + Allow Bluetooth to connect with Ledger NSCameraUsageDescription QR Scan NSFaceIDUsageDescription diff --git a/src/components/Error.tsx b/src/components/Error.tsx index e40aa325..62922d6f 100644 --- a/src/components/Error.tsx +++ b/src/components/Error.tsx @@ -32,7 +32,11 @@ const Error = ({title, content} : { title?: string, content?: string }): ReactEl lineHeight: 21, }} > - {content || 'You have encountered an error'} + { + (typeof content === 'object' || !content) ? + 'You have encountered an error' : + content + } ) diff --git a/src/screens/auth/AuthMenu.tsx b/src/screens/auth/AuthMenu.tsx index 564cb416..4080d002 100644 --- a/src/screens/auth/AuthMenu.tsx +++ b/src/screens/auth/AuthMenu.tsx @@ -19,6 +19,7 @@ import { navigationHeaderOptions } from 'components/layout/Header' import { AuthStackParams } from 'types' import TopupStore from 'stores/TopupStore' +import { requestPermissionBLE } from 'utils/permission' const AuthMenu = (): ReactElement => { const [initPageComplete, setInitPageComplete] = useState(false) @@ -32,6 +33,16 @@ const AuthMenu = (): ReactElement => { setInitPageComplete(true) } + const grantingBLE = async (): Promise => { + const requestResult = await requestPermissionBLE() + if (requestResult === 'granted') { + navigate('ConnectLedger') + return + } else { + return + } + } + useEffect(() => { initPage() }, []) @@ -103,7 +114,7 @@ const AuthMenu = (): ReactElement => { theme={'white'} title={'Access with Ledger'} onPress={(): void => { - navigate('ConnectLedger') + grantingBLE() }} containerStyle={{ marginBottom: 10 }} /> diff --git a/src/utils/permission.ts b/src/utils/permission.ts index 4bfac2cf..2ab457ae 100644 --- a/src/utils/permission.ts +++ b/src/utils/permission.ts @@ -20,6 +20,14 @@ export const requestPermission = async (): Promise => { return request(permissions.CAMERA) } +export const requestPermissionBLE = async (): Promise => { + if (Platform.OS === 'android') { + return request(PERMISSIONS.ANDROID.ACCESS_FINE_LOCATION) + } else { + return 'granted' + } +} + export const openPermissionSettings = (): void => { openSettings().catch(() => { // error handling