Dolphin MOVE SDK
2.x
2.x
  • Introduction
  • MOVE Services
  • MOVE SDK
    • Getting Started
      • MOVE Dashboard
        • Access Control
        • Configuration
        • Timeline
        • Points of Interest
      • Android
        • Installation
        • Quick Start
      • iOS
        • Installation
        • Quick Start
        • Troubleshooting
      • React Native
      • Flutter
      • Move SDK CLI
    • API Interface
      • Android
        • Initialization
        • Services
      • iOS
        • Initialization
        • Setup
        • Services
      • React Native
        • Components
        • Initialization
        • Services
      • Flutter
        • Initialization
        • Services
    • Models
      • Listeners/Callbacks
      • MoveAssistanceCallStatus
      • MoveAuth
      • MoveAuthError
      • MoveAuthResult
      • MoveAuthState
      • MoveConfig
      • MoveConfigurationError
      • MoveDevice
      • MoveDeviceStatus
      • MoveGeocodeError
      • MoveHealthItem
      • MoveHealthScore
      • MoveOptions
        • DeviceDiscovery
      • MoveSdkState
      • MoveSdkAndroidConfig
      • MoveTripState
      • MoveScanResult
      • MoveServiceFailure
      • MoveServiceWarning
      • MoveShutdownResult
    • Appendix
      • Token refresh
      • Android
        • Permission Handling
          • Permission Overview
          • Runtime Permissions
        • Battery optimization
        • Notification Management
      • iOS
        • Permissions Handling
        • App Store
      • React Native
        • Permission Handling
  • MOVE Backend
    • MOVE Backend
      • MOVE Admin API
      • MOVE TIMELINE API
      • MOVE State API
      • MOVE Last Location API
    • MOVE Generic Notifier
    • MOVE Assistance Notifier
    • Example requests
  • FAQ
  • Changelog
    • Android
    • iOS
    • React
    • Flutter
    • Backend
  • Data privacy (GDPR)
Powered by GitBook
On this page
  • iOS
  • Android
  • Javascript
  • Next steps
  1. MOVE SDK
  2. API Interface
  3. React Native

Initialization

API Interface / React Native

PreviousComponentsNextServices

Last updated 3 months ago

The MOVE SDK must be initialized natively. For the first init, the SDK expects to be setup after user onboarding using Javascript. In this case, Javascript passes the required auth code or , and objects.

In all future inits, the SDK expects to be initialized natively at app start points (In AppDelegate for iOS, and MainApplication for Android). This is to guarantee that the MOVE SDK is set up and active before the limited time provided by the OS in background wakeups is consumed.

The native init will re-use the last authentication and configs objects passed to the SDK from the JS initialization.

iOS

To initialize the SDK natively, in your AppDelegate:

#import <ReactMoveSDK/MoveSdk.h>
...
- (BOOL)application:(UIApplication *)application willFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  [RCTMoveSdk initIfPossibleWithLaunchOptions:launchOptions];
  return YES;
}

Android

To initialize the SDK natively, in your MainApplication:

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);
		...
	}
}

Javascript

MoveSdk.setupWithCode(
    code: string,
    config: MoveSdkConfig,
    android: MoveSdkAndroidConfig,
    options: MoveSdkOptions
) => Promise<void>

Setup will return with a promise or throw an error on failure, such as when the code is expired or there is no network available. These errors must be caught.

MoveSdk.setup(
    config: MoveSdkConfig,
    auth: MoveSdkAuth,
    android: MoveSdkAndroidConfig,
    options: MoveSdkOptions
) => Promise<void>

Will be remove in future versions, use setupWithCode(...) instead.

Next steps

Also note that for better efficiency all listeners should be added before initialising the SDK. With this approach it's easier to track down and fix all errors and problems, that could be triggered by initialisation or occurred even before initialisation.

To setup the SDK in React Native you have to provide and auth code (provided by the backend), and . is optional object with additional SDK configurations.

Previously setup was done using a object.

The SDK will provide all relevant information on its status and ability to recognise trips. In order to have up-to-date information about the status of the SDK you can add (e.g. to be aware of every change, to be aware of every change) or request this information directly (e.g. and ).

In addition, the SDK will report all possible and that may prevent the SDK from functioning properly. Among these errors and warnings will be those that indicate a missing permission or incomplete guarantee of certain permission. This is useful for informing the user of certain problems in granting permissions to the host app. To keep track of these errors and warnings you can use listeners ( and ) or request a list of errors or warnings directly ( and ).

MoveAuth
MoveConfig
MoveSdkConfig
MoveSdkAndroidConfig
MoveSdkOptions
MoveSdkAuth
listeners
addSdkStateListener
MoveSDKState
addTripStateListener
MoveTripState
getState
getTripState
errors
warnings
addErrorsListener
addWarningsListener
getErrors
getWarnings