Skip to content

Commit

Permalink
Andynuzzo/fix require cycles + Clearing all Warnings and Bug Fixes fo…
Browse files Browse the repository at this point in the history
…r iOS (#67)

* updated README.md

Made changes for developers on macOS with Xcode 10+

* Fixed Async storage, request cycles warnings

* using patch-package to work around RNFetchBlob recursive importing

* saving patch for RNFetchBlob recursive importing

* Putting native background geo back.

* re-fix AsyncStorage

* Fixing Background services not existing on iOS

* Fixing Internationalization on Xcode

* Import Alert and add stationarylocation logging

* capitalize L

Co-authored-by: Andy Nuzzo <[email protected]>
Co-authored-by: philrouge <[email protected]>
Co-authored-by: Abhishek Singh <[email protected]>
  • Loading branch information
4 people authored Mar 16, 2020
1 parent 27243e0 commit 30b0f43
Show file tree
Hide file tree
Showing 11 changed files with 419 additions and 62 deletions.
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

A personal location vault that nobody else can access. Log your location privately every five minutes. No information will leave the phone.

**Downloads:** [Google Play](https://play.google.com/store/apps/details?id=edu.mit.privatekit) | Apple App Stored - coming soon!
**Downloads:** [Google Play](https://play.google.com/store/apps/details?id=edu.mit.privatekit) | Apple App Store - coming soon!

**Home page:** http://privatekit.mit.edu

Expand All @@ -24,15 +24,14 @@ Refer to and run the dev_setup.sh for needed tools.

### iOS Configuration - First Time Setup

1. pod install in `ios` directory
2. Open `.workspace` file in the iOS directory and run `build`
3. If you have any trouble with packages not round, try `react-native link` from project directory.
4. Look at running commands below.
1. Move to `ios` directory and run `pod install`
2. If you have any trouble with packages not round, try `react-native link` from project directory.
3. Look at running commands below.

## Running

Install modules:
```npm install``` or ```yarn install```
```npm install``` or ```yarn install``` (note ```yarn``` does a better job at installing dependencies on macOS)

To run, do:
```
Expand Down
1 change: 0 additions & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@ dependencies {
implementation project(':react-native-webview')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.facebook.react:react-native:+" // From node_modules
implementation project(':@mauron85_react-native-background-geolocation')
implementation "androidx.annotation:annotation:1.1.0"

compile project(':react-native-fs')
Expand Down
4 changes: 2 additions & 2 deletions android/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ include ':react-native-zip-archive'
project(':react-native-zip-archive').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-zip-archive/android')
include ':react-native-webview'
project(':react-native-webview').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-webview/android')
include ':@mauron85_react-native-background-geolocation-common'
project(':@mauron85_react-native-background-geolocation-common').projectDir = new File(rootProject.projectDir, '../node_modules/@mauron85/react-native-background-geolocation/android/common')
include ':@mauron85_react-native-background-geolocation'
project(':@mauron85_react-native-background-geolocation').projectDir = new File(rootProject.projectDir, '../node_modules/@mauron85/react-native-background-geolocation/android/lib')
include ':@mauron85_react-native-background-geolocation-common'
project(':@mauron85_react-native-background-geolocation-common').projectDir = new File(rootProject.projectDir, '../node_modules/@mauron85/react-native-background-geolocation/android/common')
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
include ':app'
2 changes: 1 addition & 1 deletion app/helpers/General.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {AsyncStorage} from 'react-native';
import AsyncStorage from '@react-native-community/async-storage';
import _ from 'lodash';

/**
Expand Down
24 changes: 16 additions & 8 deletions app/services/LocationService.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,16 @@ export default class LocationServices {
});
});

BackgroundGeolocation.headlessTask(async (event) => {
// Application was shutdown, but the headless mechanism allows us
// to capture events in the background. (On Android, at least)
if (event.name === 'location' || event.name === 'stationary') {
saveLocation(event.params);
}
});
if (Platform.OS === 'android') {
// This feature only is present on Android.
BackgroundGeolocation.headlessTask(async (event) => {
// Application was shutdown, but the headless mechanism allows us
// to capture events in the background. (On Android, at least)
if (event.name === 'location' || event.name === 'stationary') {
saveLocation(event.params);
}
});
}

BackgroundGeolocation.on('stationary', (stationaryLocation) => {
// handle stationary locations here
Expand All @@ -125,7 +128,12 @@ export default class LocationServices {
// execute long running task
// eg. ajax post location
// IMPORTANT: task has to be ended by endTask
saveLocation(location);

// For capturing stationaryLocation. Note that it hasn't been
// tested as I couldn't produce stationaryLocation callback in emulator
// but since the plugin documentation mentions it, no reason to keep
// it empty I believe.
saveLocation(stationaryLocation);
BackgroundGeolocation.endTask(taskKey);
});
console.log('[INFO] stationaryLocation:', stationaryLocation);
Expand Down
176 changes: 176 additions & 0 deletions dev_setup2.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
function show_help() {
echo "
Usage: dev_setup.sh [options]
Configures a Linux or MacOS machine for working with the code in this repo.
Options:
-ni Non-interactive mode, auto answers Yes to all questions.
-h, --help Show this message
"
}

for var in "$@" ; do
if [[ $var == '-h' || $var == '--help' || $var == '-?' ]] ; then
show_help
exit 0
elif [[ $var == '-ni' ]] ; then
non_interactive="Y"
else
echo "Unknown option: $var"
show_help
exit 1
fi
done


function found_exe() {
hash "$1" 2>/dev/null
}

if found_exe tput ; then
if [[ $(tput colors) != "-1" ]]; then
# Get some colors we can use to spice up messages!
GREEN=$(tput setaf 2)
BLUE=$(tput setaf 4)
CYAN=$(tput setaf 6)
YELLOW=$(tput setaf 3)
RESET=$(tput sgr0)
HIGHLIGHT=$YELLOW
fi
fi


###############################################################################
## Main setup

# Need Node.js (8.3 or newer)
#TODO: Check nodejs version? (nodejs --version)
if ! found_exe nodejs ; then
echo "${BLUE}Installing Node.js v13.x...${RESET}"
curl -sL https://deb.nodesource.com/setup_13.x | sudo -E bash -
sudo apt-get install -y nodejs
echo "${GREEN}Node.js installed!${RESET}"
fi


# Need JDK (v8 or newer)
# TODO: Check java version (java -version)
if ! found_exe java ; then
echo "${BLUE}Installing AdoptOpenJDK...${RESET}"

# Add GPG key
wget -qO - https://adoptopenjdk.jfrog.io/adoptopenjdk/api/gpg/key/public | sudo apt-key add -
sudo add-apt-repository --yes https://adoptopenjdk.jfrog.io/adoptopenjdk/deb/

# Import repo
sudo apt-get install -y software-properties-common
sudo add-apt-repository --yes https://adoptopenjdk.jfrog.io/adoptopenjdk/deb/
sudo apt-get update

# Install
sudo apt-get -y install adoptopenjdk-8-hotspot
echo "${GREEN}AdoptOpenJDK installed!${RESET}"
fi


## Need Android Studio (interactive for now)
#if ! found_exe android-studio ; then
# echo "${YELLOW}Install Android Studio from https://developer.android.com/studio/index.html${RESET}"
# echo "You can also use your software store to install."
# echo "${BLUE}Press RETURN after completing this step.${RESET}"
# read

# if ! found_exe android-studio ; then
# echo "Not able to find Android Studio still, aborting."
# exit 1
# fi

# # Need Android 9 (Pie) SDK
# echo "We need the Android 9 (Pie) SDK. Please follow these steps:"
# echo "1) Open Android Studio"
# echo "2) At bottom of the 'Welcome to Android Studio' screen click on Configure > SDK Manager"
# echo " NOTE: You might need to close and reopent Android Studio the first time to see this."
# echo " * Under the SDK Platforms tab, click Show Package Details"
# echo " * Expand the 'Android 9.0 (Pie)' entry"
# echo " - Check: Android SDK Platform 29"
# echo " - Check: Intel x86 Atom_64 System Image or Google APIs Intel x86 Atom System Image"
# echo " * Under the SDK Tools tab, check 'Show Package Details'"
# echo " * Expand the 'Android SDK Build-Tools' entry"
# echo " - Check: 28.0.3"
# echo " * Press Apply button, then OK and agree to terms to download necessary pieces."
# echo " * Press Finish button, then OK button after downloads complete."
# echo ""
# echo "${BLUE}Press RETURN after completing these steps.${RESET}"

# echo "${BLUE}Adding environment variables via ~/.profile_mobileapp${RESET}"

# echo "# ==== Added by PrivateKit/mobileapp's dev_setup.sh ====" >> ~/.profile_mobileapp
# echo "export ANDROID_HOME=\$HOME/Android/Sdk" >> ~/.profile_mobileapp
# echo "export PATH=\$PATH:\$ANDROID_HOME/emulator" >> ~/.profile_mobileapp
# echo "export PATH=\$PATH:\$ANDROID_HOME/tools" >> ~/.profile_mobileapp
# echo "export PATH=\$PATH:\$ANDROID_HOME/tools/bin" >> ~/.profile_mobileapp
# echo "export PATH=\$PATH:\$ANDROID_HOME/platform-tools" >> ~/.profile_mobileapp

# echo "source ~/.profile_mobileapp" >> ~/.profile
#
# echo "${GREEN}Android Studio installed!${RESET}"
# echo "${YELLOW}You will need to start a new terminal session for this to apply.${RESET}"
#fi


# Need Watchman v4.9+ (watchman --version)
if ! found_exe watchman ; then
echo "${BLUE}Installing Watchman, this is going to take a little bit...${RESET}"
echo "${YELLOW}TODO: Watchman setup...is it necessary?${RESET}"

# if ! found_exe brew ; then
# # Use the linuxbrew system to install 'watchman'
# sudo apt-get install linuxbrew-wrapper
# export PATH="$HOME/.linuxbrew/bin:$PATH"
# export MANPATH="$HOME/.linuxbrew/share/man:$MANPATH"
# export INFOPATH="$HOME/.linuxbrew/share/info:$INFOPATH"
# fi
# brew update && brew upgrade
#
# brew install --HEAD watchman
#
# # Then increase the amount of inotify user instances, user watches and queued events
# echo fs.inotify.max_user_instances=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
# echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
# echo fs.inotify.max_queued_events=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p


# SSP: This is the source-code version that didn't quite work
# pushd ~
# git clone https://github.com/facebook/watchman.git
# cd watchman/
# git checkout v4.9.0
# sudo apt-get install -y autoconf automake build-essential python-dev libtool m4
# ./autogen.sh
# ./configure --enable-lenient
# make
# sudo make install
# popd # Return to where we were
fi


if ! found_exe react-native ; then
echo "${BLUE}Installing React Native tool...${RESET}"
sudo npm install -g react-native-cli
npm install
echo "${GREEN}React Native tools installed!${RESET}"
fi


echo "${GREEN}You are now ready to go!${RESET}"
echo
echo "Try this to get started:"
echo
echo " Run Android Studio then:"
echo " * Select 'Configure > AVD Manager' at the bottom"
echo " * Create and run a virtula device, such as a Pixel 2"
echo
echo " In a terminal run:"
echo " $ ~/mobileapp/1_start_react.sh"
echo " In a second terminal:"
echo " $ ~/mobileapp/2_start_android_app.sh"
echo " You can edit files and repeat step 2 again as necessary to debug."
38 changes: 38 additions & 0 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -223,12 +223,28 @@ PODS:
- React-cxxreact (= 0.61.5)
- React-jsi (= 0.61.5)
- ReactCommon/jscallinvoker (= 0.61.5)
- rn-fetch-blob (0.12.0):
- React-Core
- RNCAsyncStorage (1.8.1):
- React
- RNCMaskedView (0.1.5):
- React
- RNFS (2.16.6):
- React
- RNGestureHandler (1.5.6):
- React
- RNScreens (2.0.0-alpha.12):
- React
- RNShare (3.0.0):
- React
- RNZipArchive (5.0.1):
- React
- RNZipArchive/Core (= 5.0.1)
- SSZipArchive (= 2.2.2)
- RNZipArchive/Core (5.0.1):
- React
- SSZipArchive (= 2.2.2)
- SSZipArchive (2.2.2)
- Yoga (1.14.0)

DEPENDENCIES:
Expand Down Expand Up @@ -262,14 +278,20 @@ DEPENDENCIES:
- React-RCTVibration (from `../node_modules/react-native/Libraries/Vibration`)
- ReactCommon/jscallinvoker (from `../node_modules/react-native/ReactCommon`)
- ReactCommon/turbomodule/core (from `../node_modules/react-native/ReactCommon`)
- rn-fetch-blob (from `../node_modules/rn-fetch-blob`)
- "RNCAsyncStorage (from `../node_modules/@react-native-community/async-storage`)"
- "RNCMaskedView (from `../node_modules/@react-native-community/masked-view`)"
- RNFS (from `../node_modules/react-native-fs`)
- RNGestureHandler (from `../node_modules/react-native-gesture-handler`)
- RNScreens (from `../node_modules/react-native-screens`)
- RNShare (from `../node_modules/react-native-share`)
- RNZipArchive (from `../node_modules/react-native-zip-archive`)
- Yoga (from `../node_modules/react-native/ReactCommon/yoga`)

SPEC REPOS:
trunk:
- boost-for-react-native
- SSZipArchive

EXTERNAL SOURCES:
"@mauron85_react-native-background-geolocation":
Expand Down Expand Up @@ -326,12 +348,22 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native/Libraries/Vibration"
ReactCommon:
:path: "../node_modules/react-native/ReactCommon"
rn-fetch-blob:
:path: "../node_modules/rn-fetch-blob"
RNCAsyncStorage:
:path: "../node_modules/@react-native-community/async-storage"
RNCMaskedView:
:path: "../node_modules/@react-native-community/masked-view"
RNFS:
:path: "../node_modules/react-native-fs"
RNGestureHandler:
:path: "../node_modules/react-native-gesture-handler"
RNScreens:
:path: "../node_modules/react-native-screens"
RNShare:
:path: "../node_modules/react-native-share"
RNZipArchive:
:path: "../node_modules/react-native-zip-archive"
Yoga:
:path: "../node_modules/react-native/ReactCommon/yoga"

Expand Down Expand Up @@ -364,9 +396,15 @@ SPEC CHECKSUMS:
React-RCTText: 9ccc88273e9a3aacff5094d2175a605efa854dbe
React-RCTVibration: a49a1f42bf8f5acf1c3e297097517c6b3af377ad
ReactCommon: 198c7c8d3591f975e5431bec1b0b3b581aa1c5dd
rn-fetch-blob: f065bb7ab7fb48dd002629f8bdcb0336602d3cba
RNCAsyncStorage: e0dd7c8a36543b4ef84969acd9f8aceba3a92dc2
RNCMaskedView: dd13f9f7b146a9ad82f9b7eb6c9b5548fcf6e990
RNFS: 2bd9eb49dc82fa9676382f0585b992c424cd59df
RNGestureHandler: 911d3b110a7a233a34c4f800e7188a84b75319c6
RNScreens: 254da4b84f25971cbb30ed3ddc84131f23cac812
RNShare: 0e19ddb0bf338b62702ce1d9e001ee14effa68a8
RNZipArchive: 87111bb6130a38edd68c8d2059d46ac94d53ffe4
SSZipArchive: fa16b8cc4cdeceb698e5e5d9f67e9558532fbf23
Yoga: f2a7cd4280bfe2cca5a7aed98ba0eb3d1310f18b

PODFILE CHECKSUM: a72444a1c8c7fce528829dd576584854ab2bb99a
Expand Down
Loading

0 comments on commit 30b0f43

Please sign in to comment.