
# localytics-react-native

Native bindings for the [Localytics](https://www.localytics.com/) iOS and
Android SDKs.

## Development Setup

#### Node, Watchman, and the React Native CLI are required for development.

1. `brew install node` Note: If you already have Node, make sure it is version 4 or newer.
2. `brew install watchman`
3. `brew install yarn`
3. `npm install -g react-native-cli`

#### Java version 8 is required to run Android

You may see this error: `Could not determine java version from '9.0.1’.`
https://stackoverflow.com/questions/46867399/react-native-error-could-not-determine-java-version-from-9-0-1

Download JDK8: http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

## Running LLReactNativeTemplateApp
#### Run the following commands to pull the required `node_modules`

1. `$ cd LLReactNativeTemplateApp/`
2. `$ npm install`
3. `$ npm install localytics-react-native-dev --save`

#### Next, link the wrapper...

### Automatic Linking

`$ react-native link localytics-react-native-dev`

### Manual Linking

#### iOS

1. In XCode, in the project navigator, right click `Libraries` ➜ `Add Files to [your project's name]`
2. Go to `node_modules` ➜ `localytics-react-native-dev` and add `LLLocalytics.xcodeproj`
3. In XCode, in the project navigator, select your project. Add `libLLLocalytics.a` to your project's `Build Phases` ➜ `Link Binary With Libraries`
4. Run your project (`Cmd+R`)<

#### Android

1. Open up `android/app/src/main/java/[...]/MainActivity.java`
  - Add `import com.localytics.react.android.LLLocalyticsPackage;` to the imports at the top of the file
  - Add `new LLLocalyticsPackage()` to the list returned by the `getPackages()` method
2. Append the following lines to `android/settings.gradle`:
  	```
  	include ':localytics-react-native-dev'
  	project(':localytics-react-native-dev').projectDir = new File(rootProject.projectDir, 	'../node_modules/localytics-react-native-dev/android')
  	```
3. Insert the following lines inside the dependencies block in `android/app/build.gradle`:
  	```
      compile project(':localytics-react-native-dev')
  	```

### Use the following commands to run your project

#### iOS
1. `react-native run-ios`

#### Android
1. ensure you have a physical device in debugging mode connected to your computer, or an Android emulator running.
2. `react-native run-android`
