react-native-beacons-manager权限.ACCESS_FINE_LOCATION

问题描述

使用https://github.com/MacKentoch/react-native-beacons-manager

控制台中仍然有错误never_ask_again 我仍然拒绝位置访问,并且不知道如何解决。 怎么了。

我在build.gralde中的构建脚本:

buildscript {
    ext {
        buildToolsversion = "29.0.2"
        minSdkVersion = 16
        compileSdkVersion = 29
        targetSdkVersion = 29
    }

我在宣言“权限”中读到这个版本,添加自己。 当我手动添加权限时。 react-native run-android删除此权限。

import React,{ Component } from 'react';
import { View,deviceeventemitter,ListView,Text} from 'react-native';
import Beacons  from 'react-native-beacons-manager';
import {PermissionsAndroid} from 'react-native';


export default class App extends Component {

  async componentDidMount() {

    try {
      const granted = await PermissionsAndroid.request(
      PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION,{
              'title': 'Location Permission','message': 'Activeev needs to access your location.'
          }
      )
      console.log('here',granted);
      

      if (granted === PermissionsAndroid.RESULTS.GRANTED) {
          console.log("Location Permitted")
           // Start detecting all iBeacons in the nearby
            Beacons.detectIBeacons();

            Beacons.startRangingBeaconsInRegion('one','2cbe4ba8-1c4d-456f-9d43-6ab72499d99c').then((data)=>{   
                console.log(data);   
            })
            .catch((reason) => {   
                console.log(reason);   
            });

            // Print a log of the detected iBeacons (1 per second)
            deviceeventemitter.addListener('beaconsDidRange',(data) => {
              console.log(data);
            });
      } else {
          console.log("Location permission denied")
      }

    }catch (err) {
        console.warn(err)
    }

  }  

 render(){
   return(
     <View></View>
   );
 }

}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)