1.0.1 • Published 5 years ago

react-native-hms-location v1.0.1

Weekly downloads
10
License
-
Repository
-
Last release
5 years ago

react-native-hms-location

Contents

  • Introduction
  • Installation Guide
  • React-Native SDK Method Definition
  • Configuration Description
  • Licensing and Terms

1. Introduction

The React-Native SDK code encapsulates the Huawei location client interface. It provides many APIs for your reference or use.

The React-Native SDK code package is described as follows:

  • Android: core layer, bridging Location SDK bottom-layer code;
  • src/modules: Android interface layer, which is used to parse the received data, send requests and generate class instances.
  • index.js: external interface definition layer, which is used to define interface classes or reference files.

2. Installation Guide

Before using Reactive-Native SDK code, ensure that the RN development environment has been installed.

2.1 Copy the library into the demo project

In order to able the library to be used in the demo, the library should be copied under the node_modules folder of the project.

The structure should be like this

        hms-location-demo
            |_ node_modules
                |_ ...
                    react-native-hms-location
                    ...

2.2 Add location package to your application

import com.huawei.hms.rn.location.RNHMSLocationPackage

Then add the following line to your getPackages() method.

packages.add(new RNHMSLocationPackage()); 

2.3 Initialize the broadcast receiver within your app

Import the following classes to the MainActivity.java file of your project.

import com.huawei.hms.rn.location.RNHMSLocationPackage;
import com.huawei.hms.rn.location.helpers.HMSBroadcastReceiver;

Then add the following line to your onCreate() method:

HMSBroadcastReceiver.init(this, getReactNativeHost().getReactInstanceManager());

3. HUAWEI Location Kit SDK for React Native

Summary

Fused Location
LocationDataObject used used to store location data.
LocationRequestObject used to store location request information.
LocationSettingsRequestObject used for specifying the location service types and checking the location settings to obtain optimal functionality of all requested services.
flushLocationsThis API is used to update locations being processed.
checkLocationSettingsThis API is used to check whether related location settings are available.
getLastLocationThis API is used to obtain the latest available location.
getLastLocationWithAddressThis API is used to obtain the available location of the last request, including the detailed address information.
getLocationAvailabilityThis API is used to check whether the location data is available.
setMockLocationThis API is used to update locations being processed.
setMockModeThis API is used to specify whether the location provider uses the location mock mode. If yes, the GPS or network location is not used and the location set through setMockLocation (Location) is directly returned.
requestLocationUpdatesWithCallbackThis API is used to request location updates.
removeLocationUpdatesThis API is used to remove location updates of the specified callback information.
requestPermissionThis API is used to request permission to use location services.
hasPermissionThis API is used to check if the permission to use location services has been granted.
addFusedLocationEventListenerThis method is used add a listener for fused location events.
removeFusedLocationEventListenerThis method is used to remove the listener added for fused location events.
Activity Identification
ActivityConversionInfoThis object is used to store activity conversion information.
ActivityConversionDataThis object is used to store activity conversion event data.
ActivityConversionRequestThis object is used to store activity conversion request information.
ActivityConversionResponseThis object is used to store activity conversion result information.
ActivityIdentificationDataThis object is used to store activity identification event data.
ActivityIdentificationResponseThis object is used to store activity identification result data.
createActivityConversionUpdatesThis API is used to activity conversions (entering and exit), for example, detecting user status change from walking to bicycling.
createActivityIdentificationUpdatesThis API is used to register for activity identification updates.
deleteActivityConversionUpdatesThis API is used to remove activity conversion updates associated with the given pendingIntent object.
deleteActivityIdentificationUpdatesThis API is used to remove all activity identification updates from the specified PendingIntent object.
requestPermissionThis API is used to request permission to use activity identification services.
hasPermissionThis API is used to check if the permission to use activity identfication services has been granted.
addActivityIdentificationEventListenerThis method is used add a listener for activity identification events.
removeActivityIdentificationEventListenerThis method is used to remove the listener added for activity identification events.
addActivityConversionEventListenerThis method is used add a listener for activity conversion events.
removeActivityConversionEventListenerThis method is used to remove the listener added for activity conversion events.
GeoFence
GeofenceBuilderThis object is used to store geofence data.
GeofenceRequestThis object is used to store geofence request information.
GeofenceDataThis object is used to store geofence event data.
createGeofenceListThis API is used to add multiple geofences.
deleteGeofenceListThis API is used to remove geofences by their request IDs. An error is reported if the list is empty.
addGeofenceEventListenerThis method is used add a listener for geofence events.
removeGeofenceEventListenerThis method is used to remove the listener added for activity conversion events.

4. Configure parameters.

No.

5. Licensing and Terms

Huawei Reactive-Native SDK uses the Apache 2.0 license.