diff --git a/android/app/build.gradle b/android/app/build.gradle index f09d052..0ecfda9 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -197,6 +197,9 @@ android { } dependencies { + implementation project(':@react-native-community_geolocation') + implementation project(':react-native-ble-manager') + implementation project(':react-native-wifi-reborn') implementation fileTree(dir: "libs", include: ["*.jar"]) implementation "com.facebook.react:react-native:+" // From node_modules diff --git a/android/app/src/main/java/com/rn_air_monitor/MainApplication.java b/android/app/src/main/java/com/rn_air_monitor/MainApplication.java index 50e8725..f12a368 100644 --- a/android/app/src/main/java/com/rn_air_monitor/MainApplication.java +++ b/android/app/src/main/java/com/rn_air_monitor/MainApplication.java @@ -5,6 +5,9 @@ import com.facebook.react.PackageList; import com.facebook.react.ReactApplication; +import com.reactnativecommunity.geolocation.GeolocationPackage; +import it.innove.BleManagerPackage; +import com.reactlibrary.rnwifi.RNWifiPackage; import com.facebook.react.ReactNativeHost; import com.facebook.react.ReactPackage; import com.facebook.soloader.SoLoader; diff --git a/android/settings.gradle b/android/settings.gradle index 7046115..6f2a69f 100644 --- a/android/settings.gradle +++ b/android/settings.gradle @@ -1,4 +1,10 @@ rootProject.name = 'rn_air_monitor' +include ':@react-native-community_geolocation' +project(':@react-native-community_geolocation').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-community/geolocation/android') +include ':react-native-ble-manager' +project(':react-native-ble-manager').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-ble-manager/android') +include ':react-native-wifi-reborn' +project(':react-native-wifi-reborn').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-wifi-reborn/android') apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings) include ':app' include ':react-native-camera' diff --git a/ios/Podfile b/ios/Podfile index 40a9d96..2e34f32 100644 --- a/ios/Podfile +++ b/ios/Podfile @@ -37,6 +37,12 @@ pod 'react-native-camera', path: '../node_modules/react-native-camera', subspecs pod 'Permission-Camera', :path => "#{permissions_path}/Camera.podspec" + pod 'RNWifi', :path => '../node_modules/react-native-wifi-reborn' + + pod 'react-native-ble-manager', :path => '../node_modules/react-native-ble-manager' + + pod 'react-native-geolocation', :path => '../node_modules/@react-native-community/geolocation' + target 'rn_air_monitorTests' do inherit! :search_paths # Pods for testing diff --git a/ios/Podfile.lock b/ios/Podfile.lock index a138257..9ae7702 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -381,6 +381,8 @@ PODS: - React-cxxreact (= 0.60.5) - React-jsi (= 0.60.5) - React-jsinspector (0.60.5) + - react-native-ble-manager (7.1.1): + - React - react-native-camera (3.13.1): - React - react-native-camera/RCT (= 3.13.1) @@ -395,6 +397,10 @@ PODS: - React - react-native-camera/RN (3.13.1): - React + - react-native-geolocation (2.0.2): + - React + - react-native-spinkit (1.4.1): + - React - React-RCTActionSheet (0.60.5): - React-Core (= 0.60.5) - React-RCTAnimation (0.60.5): @@ -435,6 +441,8 @@ PODS: - React - RNScreens (1.0.0-alpha.23): - React + - RNWifi (2.2.0): + - React - yoga (0.60.5.React) DEPENDENCIES: @@ -452,8 +460,11 @@ DEPENDENCIES: - React-jsi (from `../node_modules/react-native/ReactCommon/jsi`) - React-jsiexecutor (from `../node_modules/react-native/ReactCommon/jsiexecutor`) - React-jsinspector (from `../node_modules/react-native/ReactCommon/jsinspector`) + - react-native-ble-manager (from `../node_modules/react-native-ble-manager`) - react-native-camera (from `../node_modules/react-native-camera`) - react-native-camera/BarcodeDetectorMLKit (from `../node_modules/react-native-camera`) + - "react-native-geolocation (from `../node_modules/@react-native-community/geolocation`)" + - react-native-spinkit (from `../node_modules/react-native-spinkit`) - React-RCTActionSheet (from `../node_modules/react-native/Libraries/ActionSheetIOS`) - React-RCTAnimation (from `../node_modules/react-native/Libraries/NativeAnimation`) - React-RCTBlob (from `../node_modules/react-native/Libraries/Blob`) @@ -469,6 +480,7 @@ DEPENDENCIES: - RNPermissions (from `../node_modules/react-native-permissions`) - RNReanimated (from `../node_modules/react-native-reanimated`) - RNScreens (from `../node_modules/react-native-screens`) + - RNWifi (from `../node_modules/react-native-wifi-reborn`) - yoga (from `../node_modules/react-native/ReactCommon/yoga`) SPEC REPOS: @@ -526,8 +538,14 @@ EXTERNAL SOURCES: :path: "../node_modules/react-native/ReactCommon/jsiexecutor" React-jsinspector: :path: "../node_modules/react-native/ReactCommon/jsinspector" + react-native-ble-manager: + :path: "../node_modules/react-native-ble-manager" react-native-camera: :path: "../node_modules/react-native-camera" + react-native-geolocation: + :path: "../node_modules/@react-native-community/geolocation" + react-native-spinkit: + :path: "../node_modules/react-native-spinkit" React-RCTActionSheet: :path: "../node_modules/react-native/Libraries/ActionSheetIOS" React-RCTAnimation: @@ -558,6 +576,8 @@ EXTERNAL SOURCES: :path: "../node_modules/react-native-reanimated" RNScreens: :path: "../node_modules/react-native-screens" + RNWifi: + :path: "../node_modules/react-native-wifi-reborn" yoga: :path: "../node_modules/react-native/ReactCommon/yoga" @@ -602,7 +622,10 @@ SPEC CHECKSUMS: React-jsi: 4d8c9efb6312a9725b18d6fc818ffc103f60fec2 React-jsiexecutor: 90ad2f9db09513fc763bc757fdc3c4ff8bde2a30 React-jsinspector: e08662d1bf5b129a3d556eb9ea343a3f40353ae4 + react-native-ble-manager: 68833265de44288e0de78d26a069a3b8aa476a09 react-native-camera: 0a8d6bb1c1c8bcdf1d6d9105b418ac8b0fe35af9 + react-native-geolocation: cbd9d6bd06bac411eed2671810f454d4908484a8 + react-native-spinkit: da294fd828216ad211fe36a5c14c1e09f09e62db React-RCTActionSheet: b0f1ea83f4bf75fb966eae9bfc47b78c8d3efd90 React-RCTAnimation: 359ba1b5690b1e87cc173558a78e82d35919333e React-RCTBlob: 5e2b55f76e9a1c7ae52b826923502ddc3238df24 @@ -618,8 +641,9 @@ SPEC CHECKSUMS: RNPermissions: 332fd0d0c33ba71d83a22f584fce7b2270488ae0 RNReanimated: b2ab0b693dddd2339bd2f300e770f6302d2e960c RNScreens: f28b48b8345f2f5f39ed6195518291515032a788 + RNWifi: d493fe077608b0f3ce3fb3789976beffcc753d8c yoga: 312528f5bbbba37b4dcea5ef00e8b4033fdd9411 -PODFILE CHECKSUM: 5799970f64160053fd79b84ded539bf6b59ef4ba +PODFILE CHECKSUM: ac2fb7260e82ef7108979e918188e70f4a935feb COCOAPODS: 1.8.4 diff --git a/ios/rn_air_monitor/Info.plist b/ios/rn_air_monitor/Info.plist index 60bc09e..07c5fc8 100644 --- a/ios/rn_air_monitor/Info.plist +++ b/ios/rn_air_monitor/Info.plist @@ -40,7 +40,7 @@ NSCameraUsageDescription Need permission to access camera to scan QR code NSLocationWhenInUseUsageDescription - + Need permission to access Location data UILaunchStoryboardName LaunchScreen UIRequiredDeviceCapabilities diff --git a/src/components/Constants/globalConstants.js b/src/components/Constants/globalConstants.js index 8d962bc..9613b0b 100644 --- a/src/components/Constants/globalConstants.js +++ b/src/components/Constants/globalConstants.js @@ -3,4 +3,5 @@ export default class GlobalConstants { static SERVER_DOMAIN_NAME = 'https://scottgale.appspot.com/'; static SAVE_WEAR_DATA = 'save_wear_data'; static WEARABLE_NAME_PREFIX = 'WAIRU'; + static WEARABLE_NAME_PREFIX_IOS = 'WAiru-'; } diff --git a/src/components/screens/Register/BleDeviceRegistration/BleDeviceRegistration.js b/src/components/screens/Register/BleDeviceRegistration/BleDeviceRegistration.js index 17bc6f7..5b7399a 100644 --- a/src/components/screens/Register/BleDeviceRegistration/BleDeviceRegistration.js +++ b/src/components/screens/Register/BleDeviceRegistration/BleDeviceRegistration.js @@ -27,10 +27,16 @@ const bleManagerEmitter = new NativeEventEmitter(BleManagerModule); * These UUIDs base on the configuration on the device side * @Note: Once we change these UUIDs, the same changes need to be made on the firmware side and vice versa */ -const pms_service = '000000ff-0000-1000-8000-00805f9b34fb'; -const pms_service_read_noti = '0000ff01-0000-1000-8000-00805f9b34fb'; -const pms_service_write = '0000ff03-0000-1000-8000-00805f9b34fb'; -const wifi_addr_service_read = '0000ff04-0000-1000-8000-00805f9b34fb'; +pms_service = '000000ff-0000-1000-8000-00805f9b34fb'; +pms_service_read_noti = '0000ff01-0000-1000-8000-00805f9b34fb'; +pms_service_write = '0000ff03-0000-1000-8000-00805f9b34fb'; +wifi_addr_service_read = '0000ff04-0000-1000-8000-00805f9b34fb'; +if (Platform.OS === 'ios') { + pms_service = '00FF'; + pms_service_read_noti = 'FF01'; + pms_service_write = 'FF03'; + wifi_addr_service_read = 'FF04'; +} // @todo: Add mac address to firebase corresponding to the user export default class BleDeviceRegistration extends Component { @@ -322,7 +328,7 @@ export default class BleDeviceRegistration extends Component { });*/ BleManager.retrieveServices(peripheral.id).then( peripheralInfo => { - // console.log(peripheralInfo); + console.log(peripheralInfo); setTimeout(() => { this.readWiFiMacAddress(peripheral.id) .then(data => { @@ -402,7 +408,8 @@ export default class BleDeviceRegistration extends Component { */ if ( item.name && - item.name.includes(GlobalConstants.WEARABLE_NAME_PREFIX) > 0 + (item.name.includes(GlobalConstants.WEARABLE_NAME_PREFIX) > 0 || + item.name.includes(GlobalConstants.WEARABLE_NAME_PREFIX_IOS)) ) { return (