Get Started

To help with React Native development, we've put together a React Native module. In conjunction with a sample React Native app and our iOS and 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:

1. Install the Module

  1. Install the module
npm install @foursquare/movement-sdk-react-native
yarn add @foursquare/movement-sdk-react-native
  1. Link native code with autolinking
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:
// 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.

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

  1. Ensure the CFBundleIdentifier of your project's Info.plist is correctly added to your Foursquare Developer Console app's iOS Bundle IDs setting. For more details on how to set this up, please read how to Register App Bundle ID for the Movement SDK for iOS.
  2. Ensure you Configure App 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:

    For example:

// 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
  }

  ...

}

Don't forget to use your actual CONSUMER_KEY and CONSUMER_SECRET, which can be retrieved from your Foursquare Developer Console.

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

  1. In android/app/build.gradle modify the signingConfigs section to use your keystore file and ensure the storePassword, keyAlias, and keyPassword are set correctly:
signingConfigs {
     debug {
       storeFile file('/path/to/file.keystore')
       storePassword 'storePassword'
       keyAlias 'keyAlias'
       keyPassword 'keyPassword'
     }
   }
  1. Ensure the SHA1 key hash of your project is correctly added to your Foursquare Developer Console app's Android Key Hashes setting. For more details on how to set this up, please read how to Register App Key Hashes for the Movement SDK for Android.