react-native-fused-location

在 Android 上使用新的 Fused API 的 react-native 的最佳位置库。「Finest location for react-native on Android using the new Fused API.」

Github stars Tracking Chart

react-native-fused-location

npm version
npm
Package Quality
MIT Licence

Get the finest location on Android using Fused API.
I created this react native module with an inspiration that none of react native's location libraries use the newer Fused API to get location. According to google, it is the most accurate way to get location in an Android device and judges by itself when to use GPS or cell towers/wifi. Thus, it works with both.

Install

npm install react-native-fused-location --save

or

yarn add react-native-fused-location

react-native link react-native-fused-location

• in android/app/build.gradle:

dependencies {
    ...
    compile "com.facebook.react:react-native:+"  // From node_modules
+   compile project(':react-native-fused-location')
}

• in android/settings.gradle:

...
include ':app'
+ include ':react-native-fused-location'
+ project(':react-native-fused-location').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fused-location/android')

• in MainApplication.java:

+ import com.mustansirzia.fused.FusedLocationPackage;

    @Override
        protected List<ReactPackage> getPackages() {
          return Arrays.<ReactPackage>asList(
              ...
+             new FusedLocationPackage(),
              ...
              new MainReactPackage()
          );
        }

Migration to AndroidX. - BREAKING CHANGE in 1.0.0.

• Version 1.0.0 and above of this libary now makes use of AndroidX namespace instead of the legacy android support library namespace. If your app hasn't migrated to AndroidX yet, consider doing so or instead use an older version of this library such as 0.5.1. React Native 0.59 uses AndroidX.

To enable AndroidX add these two lines in your android/gradle.properties file.

android.useAndroidX=true
android.enableJetifier=true

If this doesn't work out. Check out this official guide from Google.

A guide more specific to React Native would be here.

Permissions.

Add this to your AndroidManifest.xml:

    ...
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
    ...
        <permission
            android:name="android.permission.ACCESS_COARSE_LOCATION"
            android:protectionLevel="signature" />
        <permission
                android:name="android.permission.ACCESS_FINE_LOCATION"
                android:protectionLevel="signature"/>
    ...            

Usage.

API.

Main metrics

Overview
Name With OwnerMustansirZia/react-native-fused-location
Primary LanguageJava
Program languageJava (Language Count: 3)
PlatformAndroid
License:MIT License
所有者活动
Created At2017-06-11 09:01:40
Pushed At2022-02-12 20:08:14
Last Commit At2022-01-02 21:14:38
Release Count3
Last Release Name1.1.2 (Posted on )
First Release Name1.0.0 (Posted on )
用户参与
Stargazers Count127
Watchers Count9
Fork Count35
Commits Count81
Has Issues Enabled
Issues Count37
Issue Open Count12
Pull Requests Count11
Pull Requests Open Count5
Pull Requests Close Count2
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private