@mistsys/react-native-mistsdk
v0.1.5
Published
Mist Indoor Location sdk package
Downloads
22
Keywords
Readme
React Native Mist SDK
iOS and Android wrapper for Mist Location SDK iOS and Mist Location SDK Android
Requirements
- Minimum Android SDK: API 26.
- iOS deployment Target: 14.0 or later.
- Access to the Mist Account
- Mobile SDK secret
Installation
- To install the package, inside your project directory, run:
$npm install @mistsys/react-native-mistsdk - For
androidUser need to ask Bluetooth and location permissions from the react-native app side. - For
iOSfollow the below steps: - To provide bluetooth and motion sensor permission, add NSBluetoothAlwaysUsageDescription and NSMotionUsageDescription key with a string value in the info.plist file inside the ios folder.
<key>NSBluetoothAlwaysUsageDescription</key> <String> Mist wants to access the Bluetooth in background </String> <key>NSMotionUsageDescription</key> <String> Motion sensor data is used to provide a more accurate indoor location estimate. </String> - For Setup Podfile inside ios folder according to react native documentation, so the Podfile will look like this:
target 'YourTargetName' do .... .... pod 'react-native-mistsdk', path: '../node_modules/@mistsys/react-native-mistsdk' # add this line end - Change the directory to your
iosfolder and run the below command.$pod install
Integration Guide
Import the libraries from react-native.
TypeScript:
import {NativeEventEmitter, NativeModules} from 'react-native';Create an object for NativeModules to access the Mist SDK callbacks.
TypeScript:
const MistSDK = NativeModules.RNMistsdk ; const MistSDKEvents = new NativeEventEmitter(MistSDK);Start the Mist SDK with the Mobile SDK token.
TypeScript:
MistSDK.startWithToken(MIST_SDK_TOKEN);Once we have taken all the above steps, we will be able to get all the required information in the respective callbacks.
onMapUpdate
It will be called once the map gets updated – which means that, if the device moves from one floor to another floor, there will be a change in the floor map. In such a scenario this callback will be triggered with an updated floor map.
| Attribute | Datatype | Description | | ------------- | -----------|-------------------------------------------------| | mapId | String |Unique identifier of the map. | | name | String |It is the name of the map (Floor plan) | | ppm | double |The number of pixels per meter. | | url | String |This is the url which contains the actual map. |
TypeScript:
MistSDKEvents.addListener('onMapUpdate', (map) => {
console.log(map);
});onRelativeLocationUpdate
The main purpose of this method is to provide a relativeLocation, which provides detailed information about the current location of the device.
| Attribute | Datatype | Description | | ------------- | -----------|-------------------------------------------------| | mapId | String |It provides id of the MistMap. | | x | double |It is a spatial coordinate x (in px). | | y | double |It is a spatial coordinate y (in px). | | lat | double | It mentions the current latitude of the device. | | lan | double | It mentions the current longitude of the device.|
TypeScript:
MistSDKEvents.addListener('onRelativeLocationUpdate', (relativeLocation) => {
console.log(relativeLocation);
});onRecievedAllMaps
This method will give us maps for all sites in the entire organization. It gives us the array of maps which is supposed to be of MistMap type. (Properties were explained in detail onMapUpdate method explanation).
TypeScript:
MistSDKEvents.addListener('onReceivedAllMaps', (maps) => {
console.log(maps);
});onEnterZone
This method will be triggered when the app enters our monitoring region (the area we marked as a zone in our MistMap).
| Attribute | Datatype | Description | | ------------- | -----------|---------------------------------------------------| | zoneId | String |Unique identifier of the zone. | | name | String |Name of the zone. | | mapId | String |The map ID associated with the zone event. | | userId | String |The user ID associated with the zone event. | | orgId | String |The organisation ID associated with the zone event.| | siteId | String |The site ID associated with the zone event. | | recipient | String |The recipient of the zone event. | | type | String |The trigger associated with the zone event. |
TypeScript:
MistSDKEvents.addListener('onEnterZone', (zone) => {
console.log(zone);
});onExitZone
This method will be triggered when the app exits our monitoring region (the area we marked as a zone in our MistMap).
| Attribute | Datatype | Description | | ------------- | -----------|---------------------------------------------------| | zoneId | String |Unique identifier of the zone. | | name | String |Name of the zone. | | mapId | String |The map ID associated with the zone event. | | userId | String |The user ID associated with the zone event. | | orgId | String |The organisation ID associated with the zone event.| | siteId | String |The site ID associated with the zone event. | | recipient | String |The recipient of the zone event. | | type | String |The trigger associated with the zone event. |
TypeScript:
MistSDKEvents.addListener('onExitZone', (zone) => {
console.log(zone);
});onRangeVirtualBeacon
Using this method, we can get the current ranging beacon, which is near to us.
| Attribute | Datatype | Description | | ------------- | -----------|-------------------------------------------------------| | name | String |Name of the Virtual Beacon. | | orgId | String |Organization identifier. | | siteId | String |Site Id. | | vbId | String |Unique Identifier of the Virtual beacon on Mist portal.| | vbUUId | String |UUID of the Virtual Beacon. | | message | String |Message associated with the virtual beacon. |
TypeScript:
MistSDKEvents.addListener('onRangeVirtualBeacon', (virtualBeacon) => {
console.log(virtualBeacon);
});onUpdateVirtualBeaconList
It will return all the available virtual beacons placed on the floorplan whenever its position and other details are changed from the Mist portal. (Properties were explained in detail onRangeVirtualBeacon method explanation).
TypeScript:
MistSDKEvents.addListener('onUpdateVirtualBeaconList', (virtualBeacons) => {
console.log(virtualBeacons);
});Note: This plugin is not supported for Expo projects.
