Skip to content

Commit c2370ee

Browse files
committed
ble premmisions android
1 parent 50d237a commit c2370ee

File tree

9 files changed

+34
-21
lines changed

9 files changed

+34
-21
lines changed

ios/Podfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ def project_pods
3333
pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
3434
pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
3535
pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'
36-
36+
37+
pod 'Permission-BluetoothPeripheral', :path => "../node_modules/react-native-permissions/ios/BluetoothPeripheral.podspec"
3738
pod 'Permission-LocationAlways', :path => "../node_modules/react-native-permissions/ios/LocationAlways.podspec"
3839
pod 'Permission-Motion', :path => "../node_modules/react-native-permissions/ios/Motion.podspec"
3940

ios/Podfile.lock

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ PODS:
112112
- nanopb/encode (= 0.3.9011)
113113
- nanopb/decode (0.3.9011)
114114
- nanopb/encode (0.3.9011)
115+
- Permission-BluetoothPeripheral (2.1.5):
116+
- RNPermissions
115117
- Permission-LocationAlways (2.1.5):
116118
- RNPermissions
117119
- Permission-Motion (2.1.5):
@@ -391,6 +393,7 @@ DEPENDENCIES:
391393
- GoogleMaps
392394
- lottie-ios (from `../node_modules/lottie-ios`)
393395
- lottie-react-native (from `../node_modules/lottie-react-native`)
396+
- Permission-BluetoothPeripheral (from `../node_modules/react-native-permissions/ios/BluetoothPeripheral.podspec`)
394397
- Permission-LocationAlways (from `../node_modules/react-native-permissions/ios/LocationAlways.podspec`)
395398
- Permission-Motion (from `../node_modules/react-native-permissions/ios/Motion.podspec`)
396399
- RCTRequired (from `../node_modules/react-native/Libraries/RCTRequired`)
@@ -477,6 +480,8 @@ EXTERNAL SOURCES:
477480
:path: "../node_modules/lottie-ios"
478481
lottie-react-native:
479482
:path: "../node_modules/lottie-react-native"
483+
Permission-BluetoothPeripheral:
484+
:path: "../node_modules/react-native-permissions/ios/BluetoothPeripheral.podspec"
480485
Permission-LocationAlways:
481486
:path: "../node_modules/react-native-permissions/ios/LocationAlways.podspec"
482487
Permission-Motion:
@@ -597,6 +602,7 @@ SPEC CHECKSUMS:
597602
lottie-ios: 85ce835dd8c53e02509f20729fc7d6a4e6645a0a
598603
lottie-react-native: 2a1a82bb326ae51331a5520de0cf706733c6db69
599604
nanopb: 18003b5e52dab79db540fe93fe9579f399bd1ccd
605+
Permission-BluetoothPeripheral: 4663a8373072abfe3099c44cb06bf10b0c16c110
600606
Permission-LocationAlways: 155e6251b757b380f6354737cae8e8d59c472495
601607
Permission-Motion: 099bc32191080089d1cb839cbae96d621a589c8f
602608
Protobuf: 176220c526ad8bd09ab1fb40a978eac3fef665f7
@@ -647,6 +653,6 @@ SPEC CHECKSUMS:
647653
RNWifi: 1747f039612dd494192ba6c8bc498606ad9f3ec4
648654
Yoga: f2a7cd4280bfe2cca5a7aed98ba0eb3d1310f18b
649655

650-
PODFILE CHECKSUM: c85d4a94c29bc88bc3f697f6b2b5831cdd10d31a
656+
PODFILE CHECKSUM: 837d1b8bd2e1fdf1485b9358860cb5287bda5d36
651657

652658
COCOAPODS: 1.9.1

ios/codeAgainstCorona.xcodeproj/xcshareddata/xcschemes/hamagen-qa.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
</Testables>
3232
</TestAction>
3333
<LaunchAction
34-
buildConfiguration = "Release"
34+
buildConfiguration = "Debug"
3535
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
3636
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
3737
launchStyle = "0"

src/actions/GeneralActions.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,7 @@ export const checkIfHideLocationHistory = () => async (dispatch: any) => {
7373
};
7474

7575
export const checkIfBleEnabled = () => async (dispatch: any) => {
76-
// await AsyncStorage.removeItem(USER_AGREE_TO_BLE)
77-
78-
79-
if (IS_IOS || !ENABLE_BLE_IN_APP) {
76+
if (!ENABLE_BLE_IN_APP) {
8077
dispatch({ type: ENABLE_BLE, payload: false });
8178
} else {
8279
try {

src/components/Loading.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,6 @@ const migrateIntersectionSickDatabase = async (dbSick: any) => {
216216

217217
if (dismissedExposures) {
218218
const parsedDismissedExposures: number[] = JSON.parse(dismissedExposures);
219-
console.log('parsedDismissedExposures', parsedDismissedExposures);
220-
221219
await dbSick.upgradeSickRecord(false, parsedDismissedExposures);
222220
}
223221
}

src/components/Main/BluetoothModal.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import BluetoothPermission from '../common/BluetoothPermission';
66
import { HeaderButton } from '../common';
77
import { PADDING_TOP, IS_SMALL_SCREEN, PADDING_BOTTOM, USER_AGREE_TO_BLE } from '../../constants/Constants';
88
import { ENABLE_BLE } from '../../constants/ActionTypes';
9+
import { initBLETracing } from '../../services/BLEService';
910

1011
const BluetoothModal = ({ navigation }) => {
1112
const dispatch = useDispatch();
@@ -16,9 +17,15 @@ const BluetoothModal = ({ navigation }) => {
1617
};
1718

1819
return (
19-
<View style={styles.container}>
20+
<View style={styles.container}>
2021
<HeaderButton type="close" onPress={handleExit} />
21-
<BluetoothPermission onEnd={navigation.goBack} />
22+
<BluetoothPermission
23+
onEnd={() => {
24+
navigation.goBack();
25+
// user agreed so start service
26+
initBLETracing();
27+
}}
28+
/>
2229
</View>
2330
);
2431
};

src/components/common/BluetoothPermission.tsx

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,19 @@ const BluetoothPermission: FunctionComponent<Props> = ({ onEnd }) => {
3030
};
3131

3232
const handlePressIOS = async () => {
33-
3433
const BTCheckStatus: PermissionStatus = await check(PERMISSIONS.IOS.BLUETOOTH_PERIPHERAL);
35-
console.log('BTCheckStatus',BTCheckStatus);
36-
37-
if(BTCheckStatus !== RESULTS.UNAVAILABLE && BTCheckStatus !== RESULTS.GRANTED) {
38-
const BTRequestStatus = await request(PERMISSIONS.IOS.BLUETOOTH_PERIPHERAL)
34+
35+
36+
if (BTCheckStatus !== RESULTS.UNAVAILABLE && BTCheckStatus !== RESULTS.GRANTED) {
37+
const BTRequestStatus = await request(PERMISSIONS.IOS.BLUETOOTH_PERIPHERAL);
38+
if (BTRequestStatus === RESULTS.GRANTED) {
39+
dispatch({ type: ENABLE_BLE, payload: true });
40+
await AsyncStorage.setItem(USER_AGREE_TO_BLE, 'true');
41+
}
3942
}
4043

41-
onEnd()
42-
};
44+
onEnd();
45+
};
4346

4447
const handlePressAndroid = async () => {
4548
onEnd();

src/constants/Constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,4 @@ export const USAGE_PRIVACY = 'USAGE_PRIVACY';
7070

7171
// BLE
7272
export const USER_AGREE_TO_BLE = 'USER_AGREE_TO_BLE';
73-
export const ENABLE_BLE = true
73+
export const ENABLE_BLE = true;

src/services/BLEService.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@ import { NativeEventEmitter, Clipboard, Alert } from 'react-native';
22
import AsyncStorage from '@react-native-community/async-storage';
33
// @ts-ignore
44
import SpecialBle from 'rn-contact-tracing';
5-
import { IS_IOS, ENABLE_BLE } from '../constants/Constants';
5+
import { IS_IOS, ENABLE_BLE, USER_AGREE_TO_BLE } from '../constants/Constants';
66
import { onError } from './ErrorService';
77
import { downloadAndVerifySigning } from './SigningService';
88
import config from '../config/config';
99
import defaultBleResponse from '../constants/defaultBleResponse.json';
1010

1111
export const initBLETracing = () => new Promise(async (resolve) => {
12-
if (ENABLE_BLE) {
12+
const userAgreed = await AsyncStorage.getItem(USER_AGREE_TO_BLE);
13+
if (ENABLE_BLE && userAgreed === 'true') {
1314
try {
1415
const UUID = '00000000-0000-1000-8000-00805F9B34FB';
1516

0 commit comments

Comments
 (0)