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

TypeError: (0 , _reactNativeGeolocationService.requestAuthorization) is not a function #251

Closed suprfamtech closed 3 years ago

suprfamtech commented 3 years ago

I'm trying to use location service in our app. Did ios setup, used function to take ios permission import { requestAuthorization } from 'react-native-geolocation-service' const permission = await requestAuthorization('whenInUse')

it throws error Error stack:

TypeError: (0 , _reactNativeGeolocationService.requestAuthorization) is not a function
    at getAuthorization$ (ShiftDetailsScreen.js:25)
    at tryCatch (runtime.js:63)
    at Generator.invoke [as _invoke] (runtime.js:293)
    at Generator.next (runtime.js:118)
    at tryCatch (runtime.js:63)
    at invoke (runtime.js:154)
    at runtime.js:189
    at tryCallTwo (core.js:45)
    at doResolve (core.js:200)
    at new Promise (core.js:66)
raghvendra007 commented 3 years ago

try this Geolocation.requestAuthorization({ authorizationLevel : "whenInUse" }).then(res=> console.log("result>>",res) )

Agontuk commented 3 years ago

There's no named export, you have to import it like this

import Geolocation from 'react-native-geolocation-service';
---
await Geolocation.requestAuthorization("whenInUse");