Dolphin MOVE SDK
SDK
1.x
1.x
  • Introduction
  • MOVE Services
  • MOVE SDK
    • Getting Started
      • MOVE Dashboard
      • Android
        • Installation
        • Quick Start
      • iOS
        • Installation
        • Quick Start
      • React Native
    • API Interface
      • Android
        • Initialization
        • Services
      • iOS
        • Initialization
        • Services
      • React Native
        • Initialization
        • Services
    • Models
      • MoveAuth
      • MoveConfig
      • MoveConfigurationError
      • MoveDeviceStatus
      • MoveSDKState
      • MoveTripState
      • MoveAuthState
      • Listeners/Callbacks
    • Appendix
      • Android
        • Token refresh
        • Permission Handling
        • Battery optimization
        • Notification Management
      • iOS
        • Permissions Handling
        • App Store
  • MOVE Backend
    • MOVE Timeline
    • MOVE State
    • MOVE Last Location
    • MOVE Generic Notifier
    • Open Api Specification
  • Changelog
    • Android
    • iOS
  • Data privacy (GDPR)
Powered by GitBook
On this page
  • iOS
  • Android
  • Javascript
  1. MOVE SDK
  2. API Interface
  3. React Native

Initialization

React Native

PreviousReact NativeNextServices

Last updated 2 years ago

The MOVE SDK can be initialized natively or through Javascript. For the first init, the SDK expects to be initialized after user onboarding using Javascript. In this case, Javascript passes the required 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:

@implementation AppDelegate
  - (BOOL)application:(UIApplication *)application willFinishLaunchingWithOptions:(NSDictionary *)launchOptions
  {
    [DolphinSdk initIfPossibleWithLaunchOptions:launchOptions];
    return YES;
  }
@end

We strongly recommend against loading UI in background wakeups, but only when it is a foreground wakeup or when the user brings the app to the foreground.

  • You can distinguish between foreground and background wakeups by checking on the in your :

if([application applicationState] == UIApplicationStateInactive) {
    [self launchUI];
}
- (void)applicationWillEnterForeground:(UIApplication *)application {
  if(rootView == nil) {
    [self launchUI];
  }
}

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;

  @Override
  public void onCreate() {
    super.onCreate();
    ....
    sdkWrapper = NativeMoveSdkWrapper.getInstance(this);
    if (sdkWrapper.isNativeInitializationEnabled()) {
    try {
      sdkWrapper.initNative();
    } catch (Throwable t) {
      // handle init Configuration Errors
    }
    ....
  }
  ....
}

Javascript

initialize: (
    config: MoveSdkConfig,
    auth: MoveSdkAuth,
    android: MoveSdkAndroidConfig
  ) => void

Parameters

config

The required SDK configurations.

auth

The user's Auth object.

launchOptions

In case it was a background wakeup, you can load the view when user brings app to foreground using Appdelegate method:

[: Any]?

The launch options passed in.

The MOVE SDK needs to be initialized before returns in iOS and before returns in Android. This guarantees that all the required SDK components are initialized and ready to handle the triggered system events.

In case the app has a login flow, you may want to delay the SDK initialization until the login process is complete. In that case, the app could start the SDK through JavaScript. Once the user is logged in, the SDK should always start before the end ofor returns.

MoveAuth
MoveConfig
application state
willFinishLaunchWithOptions
applicationWillEnterForeground
willFinishLaunchingWithOptions()
onCreate()
onCreate()
willFinishLaunchingWithOptions()
MoveConfig
MoveAuth
LaunchOptionsKey
willFinishLaunchWithOptions