react-native-fused-location

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

Github星跟踪图

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.

主要指标

概览
名称与所有者MustansirZia/react-native-fused-location
主编程语言Java
编程语言Java (语言数: 3)
平台Android
许可证MIT License
所有者活动
创建于2017-06-11 09:01:40
推送于2022-02-12 20:08:14
最后一次提交2022-01-02 21:14:38
发布数3
最新版本名称1.1.2 (发布于 )
第一版名称1.0.0 (发布于 )
用户参与
星数127
关注者数9
派生数35
提交数81
已启用问题?
问题数37
打开的问题数12
拉请求数11
打开的拉请求数5
关闭的拉请求数2
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?