2.0.2 • Published 6 days ago

@react-native-drivekit/driver-data v2.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
6 days ago

@react-native-drivekit/driver-data

React Native interface for DriveKit Driver Data

Prerequisite

Before installing @react-native-drivekit/driver-data you must have installed @react-native-drivekit/core.


Installation

Install the library:

npm install @react-native-drivekit/driver-data

Install iOS pods:

cd ios && pod install

Initialization

Android setup

If you have disabled the DriveKit auto-initialization, call initialize method inside the onCreateMethod() of your Appplication class.

// MainApplication.java
import com.reactnativedrivekit.driverdata.DriveKitDriverDataModule;
import com.reactnativedrivekitcore.DriveKitCoreModule;
import com.reactnativedrivekittripanalysis.DriveKitTripAnalysisModule;

// ...
  @Override
  public void onCreate() {
    super.onCreate();
    DriveKitCoreModule.Companion.initialize(this);
    final RNTripNotification tripNotification = new RNTripNotification("Notification title", "Notification description", R.drawable.common_google_signin_btn_icon_dark)
    final RNHeadlessJSNotification headlessJSNotification = new RNHeadlessJSNotification("Notification title", "Notification description");
    DriveKitTripAnalysisModule.Companion.initialize(tripNotification, headlessJSNotification);
    
    DriveKitDriverDataModule.Companion.initialize(); // ADD THIS LINE
    (…)
  }

iOS setup

If you have disabled the DriveKit auto-initialization, call initialize method in your AppDelegate.mm.

// AppDelegate.mm
#import <RNDriveKitDriverData/react-native-drivekit-driver-data-umbrella.h>

// ...

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  [[RNDriveKitCoreWrapper.shared initialize];
  [RNDriveKitTripAnalysisWrapper.shared initializeWithLaunchOptions:launchOptions];
  [[RNDriveKitDriverDataWrapper.shared initialize]; // ADD THIS LINE
  (…)
}

Note: If you are using Swift, initialize method is also available.

API

MethodReturn TypeiOSAndroid
getTripsOrderByDateAsc()Promise<GetTripsResponse \| null>
getTripsOrderByDateDesc()Promise<GetTripsResponse \| null>
getTrip()Promise<GetTripResponse \| null>
getRoute()Promise<Route \| null>
deleteTrip()Promise<void>

getTripsOrderByDateAsc

getTripsOrderByDateDesc

getTripsOrderByDateAsc(
  synchronizationType: SynchronizationType = 'DEFAULT',
  transportationModes: TransportationMode[] = []
): Promise<GetTripsResponse | null>

or

getTripsOrderByDateDesc(
  synchronizationType: SynchronizationType = 'DEFAULT',
  transportationModes: TransportationMode[] = []
): Promise<GetTripsResponse | null>
GetTripsResponseType
statusTripSyncStatus
trips[Trip]

To get driver's trips, you have to call the following method:

const result = await getTripsOrderByDateAsc();

or

const result = await getTripsOrderByDateDesc();

getTrip

getTrip(itinId: string): Promise<GetTripResponse | null>
GetTripResponseType
statusTripSyncStatus
tripTrip

To get a specific trip, you have to call the following method:

const result = await getTrip('TRIP_ID_HERE);

getRoute

To get road data of the trip (latitude, longitude), you have to call the following method::

getRoute(itinId: string): Promise<Route>

If route value in the callback is null, the synchronization has failed.

Example:

const route = await getRoute('TRIP_ID_HERE');

deleteTrip

To delete a trip, you have to call the following method:

deleteTrip(itinId: string): Promise<boolean>

The itinId parameter is the unique identifier for a trip.

await deleteTrip('TRIP_ID_HERE');
2.0.2

6 days ago

2.0.1

23 days ago

2.0.0

25 days ago

1.9.0

3 months ago

1.8.1

3 months ago

1.8.0

4 months ago

1.7.0

5 months ago

1.6.0

7 months ago

1.5.2

12 months ago

1.5.1

12 months ago

1.5.0

1 year ago

1.4.1

1 year ago

1.4.0

1 year ago

1.3.0

1 year ago

1.2.0

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago

0.0.3

1 year ago