To help with React Native development, we've put together a [React Native module](https://www.npmjs.com/package/@foursquare/movement-sdk-react-native). In conjunction with a [sample React Native app](https://github.com/foursquare/RNPilgrimSample) and our [iOS](https://docs.foursquare.com/developer/docs/movement-sdk-ios) and [Android](https://docs.foursquare.com/developer/docs/movement-sdk-android) docs, you should have everything you need to get up and running.

### PREREQUISITES

In order to implement the Movement SDK in your app, you must first complete the following:

- **[Movement SDK Access Enabled](https://docs.foursquare.com/developer/docs/movement-sdk-get-started)**
- **Foursquare Developer Account w/ ClientID + Secret**

## 1. Install the Module

1. Install the module

NPMYarn

```text
npm install @foursquare/movement-sdk-react-native
```

```text
yarn add @foursquare/movement-sdk-react-native
```

2. Link native code with [autolinking](https://github.com/react-native-community/cli/blob/master/docs/autolinking.md)

```text
cd ios && pod install && cd ..
```

## 2. Configure iOS Implementation

1. You must call `[[FSQMovementSdkManager shared] configureWithConsumerKey:secret:delegate:completion:] from application:didFinishLaunchingWithOptions` in a your application delegate, for example:

```objectivec
// AppDelegate.m
#import "AppDelegate.h"

#import <React/RCTBridge.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import <MovementSdk/MovementSdk.h>
#import <MovementSdk/MovementSdk-Swift.h>

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  [[FSQMovementSdkManager shared] configureWithConsumerKey:@"CONSUMER_KEY"\
                                                    secret:@"CONSUMER_SECRET"\
                                                  delegate:nil\
                                                completion:nil];

// Other react native initialization code

return YES;
}

...
@end
```

Don't forget to use your actual `CONSUMER_KEY` and `CONSUMER_SECRET`, which can be retrieved from your [Foursquare Developer Console](https://foursquare.com/developers/apps).

This allows the SDK to run in the background and send you visit notifications, even when your iOS app isn't open.

2. Ensure the `CFBundleIdentifier` of your project's `Info.plist` is correctly added to your Foursquare [Developer Console](https://foursquare.com/developers/apps/) app's iOS Bundle IDs setting. For more details on how to set this up, please read how to [Register App Bundle ID](https://docs.foursquare.com/developer/docs/movement-sdk-ios-get-started#1-register-app-bundle-id) for the Movement SDK for iOS.
3. Ensure you [Configure App Permissions](https://docs.foursquare.com/developer/docs/movement-sdk-ios-get-started#a-configure-permissions) for the Movement SDK for iOS as well.

## 2. Configure Android Implementation

1. You must call `MovementSdk.with(MovementSdk.Builder)` from `onCreate` in a your `android.app.Application` subclass, for example:

```java
// MainApplication.java
import android.app.Application;
import com.facebook.react.ReactApplication;
import com.foursquare.movement.MovementSdk;

public class MainApplication extends Application implements ReactApplication {

@Override
  public void onCreate() {
    super.onCreate();

MovementSdk.Builder builder = new MovementSdk.Builder(this)
            .consumer("CONSUMER_KEY", "CONSUMER_SECRET")
            .enableDebugLogs();
    MovementSdk.with(builder);

// Other react native initialization code
  }

...
}
```

This allows the Movement SDK to run in the background and send you visit notifications, even when your Android app isn't open.

2. In `android/app/build.gradle` modify the `signingConfigs` section to use your keystore file and ensure the `storePassword`, `keyAlias`, and `keyPassword` are set correctly:

```text
signingConfigs {
     debug {
       storeFile file('/path/to/file.keystore')
       storePassword 'storePassword'
       keyAlias 'keyAlias'
       keyPassword 'keyPassword'
     }
   }
```

3. Ensure the `SHA1` key hash of your project is correctly added to your Foursquare [Developer Console](https://foursquare.com/developers/apps/) app's Android Key Hashes setting. For more details on how to set this up, please read how to [Register App Key Hashes](https://docs.foursquare.com/developer/docs/movement-sdk-android-get-started#1-register-your-apps-key-hashes) for the Movement SDK for Android.
