Agontuk / react-native-geolocation-service

React native geolocation service for iOS and android
https://www.npmjs.com/package/react-native-geolocation-service
MIT License
1.61k stars 292 forks source link

Does not work (Android) - always returns empty error #272

Closed talaikis closed 3 years ago

talaikis commented 3 years ago

After requesting permisions, it does nothing, just returns empty error

async function getPosition (options) {
    return new Promise((resolve, reject) => {
      getCurrentPosition(
        ({ coords: { latitude, longitude } }) => resolve({ latitude, longitude }),
        (error) => reject(error),
        options
      )
    })
  }

const hasPermission = await hasLocationPermission()
    if (!hasPermission) return

    const options = {
      accuracy: {
        android: 'balanced',
        ios: 'hundredMeters'
      },
      enableHighAccuracy: false,
      timeout: 15000,
      maximumAge: 60000,
      forceRequestLocation: true,
      showLocationDialog: false
    }

    const position = await getPosition(options) // .catch((e) => Alert.alert(`e ${JSON.stringify(e)}`)) // <-- here always generates empty "{}":
TypeError: undefined is not a function
TypeError: undefined is not a function
    at anonymous (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.test&modulesOnly=false&runModule=true:166124:108)
    at tryCallTwo (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.test&modulesOnly=false&runModule=true:28622:9)
    at doResolve (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.test&modulesOnly=false&runModule=true:28786:25)
    at Promise (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.test&modulesOnly=false&runModule=true:28645:14)
    at getPosition$ (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.test&modulesOnly=false&runModule=true:166123:60)
    at call (native)
    at tryCatch (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.test&modulesOnly=false&runModule=true:7744:23)
    at invoke (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.test&modulesOnly=false&runModule=true:7917:32)
    at anonymous (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.test&modulesOnly=false&runModule=true:7787:30)
    at call (native)
    at tryCatch (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.test&modulesOnly=false&runModule=true:7744:23)
    at invoke (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.test&modulesOnly=false&runModule=true:7817:30)
    at anonymous (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.test&modulesOnly=false&runModule=true:7847:19)
    at tryCallTwo (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.test&modulesOnly=false&runModule=true:28622:9)
    at doResolve (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.test&modulesOnly=false&runModule=true:28786:25)
    at Promise (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.test&modulesOnly=false&runModule=true:28645:14)
    at callInvokeWithMethodAndArg (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.test&modulesOnly=false&runModule=true:7846:33)
    at enqueue (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.test&modulesOnly=false&runModule=true:7851:157)
    at anonymous (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.test&modulesOnly=false&runModule=true:7787:30)
    at anonymous (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.test&modulesOnly=false&runModule=true:7868:69)
    at getPosition (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.test&modulesOnly=false&runModule=true:166119:40)
    at onSubmit$ (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.test&modulesOnly=false&runModule=true:166177:60)
    at call (native)
    at tryCatch (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.test&modulesOnly=false&runModule=true:7744:23)
    at invoke (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.test&modulesOnly=false&runModule=true:7917:32)
    at anonymous (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.test&modulesOnly=false&runModule=true:7787:30)
    at call (native)
    at tryCatch (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.test&modulesOnly=false&runModule=true:7744:23)
    at invoke (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.test&modulesOnly=false&runModule=true:7817:30)
    at anonymous (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.test&modulesOnly=false&runModule=true:7827:21)
    at tryCallOne (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.test&modulesOnly=false&runModule=true:28613:16)
    at anonymous (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.test&modulesOnly=false&runModule=true:28714:27)
    at apply (native)
    at anonymous (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.test&modulesOnly=false&runModule=true:29242:26)
    at _callTimer (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.test&modulesOnly=false&runModule=true:29130:17)
    at _callImmediatesPass (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.test&modulesOnly=false&runModule=true:29169:17)
    at callImmediates (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.test&modulesOnly=false&runModule=true:29387:33)
    at __callImmediates (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.test&modulesOnly=false&runModule=true:3268:35)
    at anonymous (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.test&modulesOnly=false&runModule=true:3046:34)
    at __guard (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.test&modulesOnly=false&runModule=true:3251:15)
    at flushedQueue (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.test&modulesOnly=false&runModule=true:3045:21)
    at invokeCallbackAndReturnFlushedQueue (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.test&modulesOnly=false&runModule=true:3038:33)

Deoendencies

"react-native": "0.64.1",
"react-native-geolocation-service": "^5.3.0-beta.1",
Agontuk commented 3 years ago

Use try/catch block if you're using async/await.