Gathering detailed insights and metrics for @deliverysolutions/react-native-proximity-sdk
Gathering detailed insights and metrics for @deliverysolutions/react-native-proximity-sdk
Gathering detailed insights and metrics for @deliverysolutions/react-native-proximity-sdk
Gathering detailed insights and metrics for @deliverysolutions/react-native-proximity-sdk
Delivery Solutions' Proximity Tracking SDK for React Native
npm install @deliverysolutions/react-native-proximity-sdk
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
47 Commits
1 Forks
1 Branches
2 Contributors
Updated on 09 Aug 2024
Cumulative downloads
Total Downloads
Last day
-66.7%
1
Compared to previous day
Last week
-83.3%
24
Compared to previous week
Last month
57.2%
393
Compared to previous month
Last year
-64.2%
3,722
Compared to previous year
21
Delivery Solutions' Proximity Tracking SDK for React Native
yarn
1yarn add @deliverysolutions/react-native-proximity-sdk 2yarn add react-native-background-fetch@~4.2.1 3yarn add react-native-background-geolocation@~4.13.1 4yarn add @react-native-async-storage/async-storage
npm
npm install @deliverysolutions/react-native-proximity-sdk --save
npm install react-native-background-fetch@~4.2.1
npm install react-native-background-geolocation@~4.13.1
npm install @react-native-async-storage/async-storage --save
react-native >= 0.60
)Add the below entry in your android/app/src/main/AndroidManifest.xml file:
1<manifest xmlns:android="http://schemas.android.com/apk/res/android" 2 package="com.transistorsoft.backgroundgeolocation.react"> 3 4 <application 5 android:name=".MainApplication" 6 android:allowBackup="true" 7 android:label="@string/app_name" 8 android:icon="@mipmap/ic_launcher" 9 android:theme="@style/AppTheme"> 10 11 <!-- react-native-background-geolocation licence --> 12+ <meta-data android:name="com.transistorsoft.locationmanager.license" android:value="YOUR_LICENCE_KEY_HERE" /> 13 . 14 . 15 . 16 </application> 17</manifest>
Import and use Proximity SDK as below:
1import Proximity from '@deliverysolutions/react-native-proximity-sdk'; 2 3class App extends Component { 4 5 componentDidMount() { 6 Proximity.init({ 7 accessToken: "<YOUR-ACCESS-TOKEN>", 8 distanceInterval: 100, 9 testMode: true, 10 logLevel: 'info' 11 }).then( async () => { 12 // check the SDK's current tracking state. 13 const isTracking = await Proximity.getTrackingState() 14 console.log(`Tracking state: ${isTracking}`); 15 16 // setup geofence handler 17 Proximity.onGeofence = (isTracking) => { 18 // stuff to do here, when user enters geofence 19 } 20 21 Proximity.onArrived = (isTracking) => { 22 // stuff to do here, when user manually calls arrived event 23 } 24 25 Proximity.onCompleted = () => { 26 // stuff to do here, when user manually calls completed event or order is marked completed 27 } 28 29 Proximity.onUpdateVehicleDetails = (vehicleDetails) => { 30 // stuff to do here, when user updates the vehicle details via updateVehicleDetails() 31 } 32 33 }) 34 } 35 36 handleStartTrackingClick = async () => { 37 38 // Set vehicle details before you start tracking, this is optional. 39 await Proximity.updateVehicleDetails({ 40 vehicleColor: 'silver | black | white | grey | blue | red | brown | green | teal | yellow', 41 vehicleMake: 'string', 42 vehicleType: 'hatchback | micro | minivan | pickup | sedan | truck | suv', 43 vehicleNumber: 'string', 44 description: 'string', 45 parkingSlot: 'string', 46 isPickupBySomeoneElse: 'boolean', 47 userName: 'string', 48 contactNumber: 'string' 49 }) 50 51 // Initiates tracking using the Order Id. Alternatively you can also use toggle tracking handler that toggles tracking based on the current tracking state. 52 const isTracking = await Proximity.startTracking({ 53 orderId: '<ORDER-ID>' 54 }) 55 console.log(`Tracking state: ${isTracking}`); 56 } 57 58 handleStopTrackingClick = async () => { 59 // Terminates tracking manually. 60 const isTracking = await Proximity.stopTracking() 61 console.log(`Tracking state: ${isTracking}`); 62 } 63}
To initialize tracking, call the init method, this will authorise the SDK with the provided accessToken
against your tenant and prepare it for tracking. accessToken must be environment dependant - for testMode as true our sandbox accessToken and for testMode as false use the production token.
testMode
(default - false) is used to switch between sandbox and production environments.logLevel
(default - 'error') is used to decide which log types/levels, of the library, should surface up in your temrinal/console.
error
, warn
, info
and debug
, with error having the highest weight and debug having the lowest.1let initObj = { 2 accessToken: '<YOUR-ACCESS-TOKEN>', // associated with your tenant 3 testMode: true, // (Optional) Default is false 4 distanceInterval: 50, // (Optional) Default is 50 (meters) 5 logLevel: 'info', // (Optional) Default is 'error' 6}; 7 8Proximity.init(initObj);
:warning: Warning: You must call init once and only once, each time your app is launched. Do not hide the call to #ready within a view which is loaded only by clicking a UI action. This is particularly important for iOS in the case where the OS relaunches your app in the background when the device is detected to be moving. If you don't ensure that init is called in this case, tracking will not resume.
This will start the tracking process for the provided orderId. The SDK will prompt the user to provide access to Location Services in case the app has no permissions set for it. This prompt is shown when the startTracking
method is triggered.
Please note, that if Location Permission is denied, then the SDK will be unable to send location to the Delivery Solutions System and only manual ETA updates would work.
In case the permission is set to When In Use
, the the location updates will be sent only when the app is in use, the user has to set the Location Permission to Always
such that the Delivery Solutions System receives location updates even when the phone is in background.
1const isTracking = await Proximity.startTracking({
2 orderId: '<ORDER-ID>' // provide orderId of the order that you want to track
3});
Manual ETA Updating should be used for following -
An ISO 8601 timestamp is provided as the parameter indicating the new ETA.
1await Proximity.updateETA('<ORDER-ID>', '2021-10-06T11:13:10.038Z');
As in the order lifecycle, store can be informed of arrival by using markArrived function.
markArrived could be called on click of a button such as "I've Arrived"
Please note, tracking will continue even though the person has arrived.
1await Proximity.markArrived('<ORDER-ID>');
As in the order lifecycle, store can be informed of the completion of order by using markCompleted function.
Generally, this is to be called when the person has collected the order and wants to notify the store that to the store and stop location tracking. This should be called only once.
1await Proximity.markCompleted('<ORDER-ID>');
By default the SDK stops tracking only when the order is marked as completed by calling markAsCompleted function. However, there might be cases when the user would want to stop the tracking manually. Call the below function to stop tracking:
1const isTracking = await Proximity.stopTracking(); // false will be returned when tracking is stopped successfully.
This method is a wrapper over stopTracking
and startTracking
methods, it will initialise tracking in case the SDK is not tracking otherwise it will stop tracking, it returns the current tracking state of the SDK.
1const isTracking = await Proximity.toggleTracking({
2 orderId: '<ORDER-ID>' // provide orderId of the order that you want to track
3});
In some cases you would want to check the state of tracking i.e. whether the tracking is already going on or not. You can call the below method to get the tracking state:
1const isTracking = await Proximity.getTrackingState(); // true indicates the tracking is in progress
The following method is used to accept the vehicle details and the contact information of the user whose location is being tracked.
1const trackingMetaData = await Proximity.updateVehicleDetails(
2 '<ORDER-ID>',
3 {
4 vehicleColor: 'silver | black | white | grey | blue | red | brown | green | teal | yellow',
5 vehicleMake: 'string',
6 vehicleType: 'hatchback | micro | minivan | pickup | sedan | truck | suv',
7 vehicleNumber: 'string',
8 description: 'string',
9 parkingSlot: 'string',
10 isPickupBySomeoneElse: 'boolean',
11 userName: 'string',
12 contactNumber: 'string'
13});
This event is triggered when the user, whose location is being tracked, enters any configured geofence boundary of the store that is associated with the order. If there is anything that you want to do once the user breached/enters the geofence boundary, then that can be done here. Currently, we support two types of geofence boundary nearby
and at-location
.
1Proximity.onGeofence = (isTracking) => { 2 // stuff to do here, when user enters geofence 3};
This event is triggered when the markArrived function is called.
1Proximity.onArrived = (isTracking) => { 2 // stuff to do here, when the location tracking has started 3};
This event is triggered when the order's vehicle details are updated by the user.
1Proximity.onUpdateVehicleDetails = ( updatedVehicleDetails ) => {
2 // stuff to do here, when the order's vehicle details are updated
3};
This event is triggered when the order has been marked as completed either by the user or by the store operator.
1Proximity.onCompleted = () => { 2 // stuff to do here, when the order has been completed 3};
This event is triggered when the markArrived function is called.
1Proximity.onArrived = (isTracking) => { 2 // stuff to do here, when the location tracking has started 3};
This event is triggered when the order's vehicle details are updated by the user.
1Proximity.onUpdateVehicleDetails = () => {
2 // stuff to do here, when the order's vehicle details are updated
3};
Please raise a ticket with DS support with details about the usage and the team shall provide the required keys.
We also offer native Android and iOS SDKs. Please contact our support team for more details.
event | DS status | Description |
---|---|---|
started | PICKUP_STARTED | The user started their journey |
arrived | PICKUP_AT_LOCATION | The user has arrived to the store |
completed | ORDER_DELIVERED | Order was delivered / picked up. |
Copyright (c) 2022 by Delivery Solutions. All Rights Reserved. Usage of this library implies agreement to abide by the license terms. Please refer to our Terms of Service.
No vulnerabilities found.
No security vulnerabilities found.