react-native-move-sdk
v2.10.2
Published
React Native library for MOVE SDK
Downloads
122
Maintainers
Readme
react-native-move-sdk
React Native library for MOVE SDK - please see https://docs.movesdk.com/move-platform for features and details about the MOVE SDK.
Installation
npm install react-native-move-sdk --save
#or
yarn add react-native-move-sdk
iOS
Add to the AppDelegate.m file
#import <ReactMoveSDK/MoveSdk.h>
...
- (BOOL)application:(UIApplication *)application willFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[RCTMoveSdk initIfPossibleWithLaunchOptions:launchOptions];
return YES;
}
Android
Add the DolphinSDK repository to the build.gradle file
// android/build.gradle
allprojects {
repositories {
maven {
url "https://dolphin.jfrog.io/artifactory/move-sdk-libs-release"
content {
includeGroup "io.dolphin.move"
}
}
}
}
Add to the MainApplication.java file
import in.dolph.move.sdk.NativeMoveSdkWrapper;
...
public class MainApplication extends Application implements ReactApplication {
private NativeMoveSdkWrapper sdkWrapper;
...
public void onCreate() {
super.onCreate();
sdkWrapper = NativeMoveSdkWrapper.getInstance(this);
sdkWrapper.init(this);
...
}
}
Usage
See https://docs.movesdk.com/move-platform/sdk/api-interface/react-native/intialization
import MoveSdk from 'react-native-move-sdk';
...
const tripChannel = {
id: 'CT',
name: 'Trips',
description: 'Trips Description',
};
const recognitionNotification: NotificationConfig = {
title: 'MOVE SDK Trip Recognition',
text: 'SDK trip recognition is running',
channel: tripChannel,
};
const tripNotification: NotificationConfig = {
title: 'MOVE SDK Trip Running',
text: 'SDK is recording your trip',
channel: tripChannel,
};
const auth = {
userId: ...,
accessToken: ...,
refreshToken: ...,
projectId: ...,
};
export const CONFIG: MoveSdkConfig = {
timelineDetectionServices: ['DRIVING', 'BICYCLE', 'PUBLIC_TRANSPORT', 'WALKING'],
drivingServices: ['DISTRACTION_FREE_DRIVING', 'DRIVING_BEHAVIOUR'],
walkingServices: []
};
export const ANDROID_CONFIG: MoveSdkAndroidConfig = {
notifications: {
recognitionNotification,
tripNotification,
}
};
MoveSdk.setup(CONFIG, auth, ANDROID_CONFIG)
Methods
See: https://docs.movesdk.com/move-platform/sdk/api-interface/react-native/services
Required permissions description ios and android...
MoveSdk.getState();
MoveSdk.resolveError();
MoveSdk.getErrors();
MoveSdk.getWarnings();
MoveSdk.startAutomaticDetection();
MoveSdk.stopAutomaticDetection();
MoveSdk.initiateAssistanceCall();
MoveSdk.shutdown();
...
Listener
MoveSdk.addSdkStateListener((state: SdkState) => {
...
});
MoveSdk.addTripStateListener((state: TripState) => {
...
});
MoveSdk.addAuthStateListener((event: AuthStateEvent) => {
...
});
MoveSdk.addAppEventListener((event: string) => {
...
});
MoveSdk.addWarningsListener((warnings: ErrorListType) => {
...
});
MoveSdk.addErrorsListener((errors: ErrorListType) => {
...
});
MoveSdk.addLogListener((log: MoveSdkLog) => {
...
});
License
MIT