Initialization
API Interface / React Native
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 MoveAuth, and MoveConfig 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:
Android
To initialize the SDK natively, in your MainApplication:
Javascript
To setup the SDK in React Native you have to provide and auth code (provided by the backend), MoveSdkConfig and MoveSdkAndroidConfig. MoveSdkOptions is optional object with additional SDK configurations.
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.
Previously setup was done using a MoveSdkAuth object.
Will be remove in future versions, use setupWithCode(...)
instead.
Next steps
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 listeners (e.g. addSdkStateListener to be aware of every MoveSDKState change, addTripStateListener to be aware of every MoveTripState change) or request this information directly (e.g. getState and getTripState).
In addition, the SDK will report all possible errors and warnings 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 (addErrorsListener and addWarningsListener) or request a list of errors or warnings directly (getErrors and getWarnings).
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.
Last updated