How to use the react-native-unimodules.Permissions.LOCATION function in react-native-unimodules

To help you get started, we’ve selected a few react-native-unimodules examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github keybase / client / shared / actions / platform-specific / index.native.tsx View on Github external
export const requestLocationPermission = async (mode: RPCChatTypes.UIWatchPositionPerm) => {
  if (isIOS) {
    const {Permissions} = require('react-native-unimodules')
    const {status, permissions} = await Permissions.getAsync(Permissions.LOCATION)
    switch (mode) {
      case RPCChatTypes.UIWatchPositionPerm.base:
        if (status === Permissions.PermissionStatus.DENIED) {
          throw new Error('Please allow Keybase to access your location in the phone settings.')
        }
        break
      case RPCChatTypes.UIWatchPositionPerm.always: {
        const iOSPerms = permissions[Permissions.LOCATION].ios
        if (!iOSPerms || iOSPerms.scope !== 'always') {
          throw new Error(
            'Please allow Keybase to access your location even if the app is not running for live location.'
          )
        }
        break
      }
    }
github NervJS / taro / packages / taro-rn / src / api / location / index.js View on Github external
export async function getLocation (opts = {}) {
  const status = await askAsyncPermissions(Permissions.LOCATION)
  if (status !== 'granted') {
    const res = {errMsg: `Permissions denied!`}
    return Promise.reject(res)
  }

  if (!opts || typeof opts !== 'object') {
    opts = {}
  }

  const {altitude = false, success, fail, complete} = opts

  return new Promise((resolve, reject) => {
    Location.getCurrentPositionAsync({
      enableHighAccuracy: Boolean(altitude)
    }).then((resp) => {
      const {coords, timestamp} = resp
github keybase / client / shared / actions / platform-specific / index.native.tsx View on Github external
export const requestLocationPermission = async (mode: RPCChatTypes.UIWatchPositionPerm) => {
  if (isIOS) {
    const {Permissions} = require('react-native-unimodules')
    const {status, permissions} = await Permissions.getAsync(Permissions.LOCATION)
    switch (mode) {
      case RPCChatTypes.UIWatchPositionPerm.base:
        if (status === Permissions.PermissionStatus.DENIED) {
          throw new Error('Please allow Keybase to access your location in the phone settings.')
        }
        break
      case RPCChatTypes.UIWatchPositionPerm.always: {
        const iOSPerms = permissions[Permissions.LOCATION].ios
        if (!iOSPerms || iOSPerms.scope !== 'always') {
          throw new Error(
            'Please allow Keybase to access your location even if the app is not running for live location.'
          )
        }
        break
      }
    }
  }
  if (isAndroid) {
    const permissionStatus = await PermissionsAndroid.request(
      PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION,
      {
        buttonNegative: 'Cancel',
        buttonPositive: 'OK',
        message: 'Keybase needs access to your location in order to post it.',