react-native-colocator-library

Colocator provides outdoor and indoor location services for mobile devices.

Usage no npm install needed!

<script type="module">
  import reactNativeColocatorLibrary from 'https://cdn.skypack.dev/react-native-colocator-library';
</script>

README

react-native-colocator-library

Getting started

$ npm install react-native-colocator-library --save

Mostly automatic installation

$ react-native link react-native-colocator-library

Additional installation steps

Android

  • Open build.grade file of Project and inside allprojects { repositotires { ... } } add 'mavem { url "http://maven.crowdconnected.net/" }'

Usage

import RNColocatorLibrary from 'react-native-colocator-library';

# Start Colocator library
RNColocatorLibrary.start("API_KEY")

# Stop Colocator library
RNColocatorLibrary.stop()

# Display Bluetooth permission popup (only in iOS)
RNColocatorLibrary.triggerBluetoothPermissionPopUp()

# Get device ID from Colocator library
RNColocatorLibrary.getDeviceID(id)=> {
  if (id) {
    console.log(id);
  }
})

# Add alias pair through Colocator library
RNColocatorLibrary.addAlias("KEY","VALUE")

# Set service notification for Colocator foreground service (only Android)
RNColocatorLibrary.setServiceNotificationInfo("SERVICE_NOTIFICATION_TEXT", kServiceNotificationIcon, "CHANNEL_ID")

# Request one location from Colocator Library
RNColocatorLibrary.requestLocation()

# Request location updates from Colocator Library
RNColocatorLibrary.registerLocationListener()

# Stop receiving location updates from Colocator Library
RNColocatorLibrary.unregisterLocationListener()

# Subscribe to location updates and handle location responses from Colocator
const colocatorEmitter = new NativeEventEmitter(RNColocatorLibrary);
subscription = colocatorEmitter.addListener(
   'LocationResponse', (response) => console.log(response)
);