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?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?