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:
- Movement SDK Access Enabled
- Foursquare Developer Account w/ ClientID + Secret
1. Install the Module
- Install the module
npm install @foursquare/movement-sdk-react-native
yarn add @foursquare/movement-sdk-react-native
- Link native code with autolinking
cd ios && pod install && cd ..
2. Configure iOS Implementation
- 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
andCONSUMER_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.
- Ensure the
CFBundleIdentifier
of your project'sInfo.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. - Ensure you Configure App Permissions for the Movement SDK for iOS as well.
2. Configure Android Implementation
-
You must call
MovementSdk.with(MovementSdk.Builder)
fromonCreate
in a yourandroid.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
andCONSUMER_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.
- In
android/app/build.gradle
modify thesigningConfigs
section to use your keystore file and ensure thestorePassword
,keyAlias
, andkeyPassword
are set correctly:
signingConfigs {
debug {
storeFile file('/path/to/file.keystore')
storePassword 'storePassword'
keyAlias 'keyAlias'
keyPassword 'keyPassword'
}
}
- 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.
Updated 9 months ago