1.EXPO的项目环境下,允许应用访问手机媒体(例如相册)的方法
import * as MediaLibrary from 'expo-media-library'; const {status} = await MediaLibrary.requestPermissionsAsync(); if (status !== 'granted') { //未授权的话,返回 console.log('Permission to access location was denied'); return; }
2.允许获取位置的办法:
import * as Location from 'expo-location'; let { status } = await Location.requestForegroundPermissionsAsync(); if (status !== 'granted') { console.log('Permission to access location was denied'); return; } const location = await Location.getCurrentPositionAsync({}); const latitude = location.coords.latitude.toFixed(6) //纬度 const longitude = location.coords.longitude.toFixed(6) //经度
3.获取IP的办法:
import * as Network from 'expo-network'; const ip: any = await Network.getIpAddressAsync(); console.log('ip',ip)
标签:status,const,log,await,API,location,操作,RN,Location From: https://www.cnblogs.com/llcdbk/p/18134968