React-native-geolocation-service: iOS module implementation

Created on 21 Apr 2020  路  5Comments  路  Source: Agontuk/react-native-geolocation-service

Hello guys, due to the pandemic I've some free time now. So I decided to learn a little bit of swift and try to implement my own geolocation module for iOS. I'll be updating this thread as I implement features one by one. You can track the progress here.

https://github.com/Agontuk/react-native-geolocation-service/tree/next

If you have any suggestions, feel free to share here.

TODO

  • [x] requestAuthorization
  • [x] getCurrentPosition
  • [x] startObserving
  • [x] stopObserving
  • [x] Background location update

API Changes

  • __setRNConfiguration (deprecated)__
    Currently it has two options skipPermissionRequests & authorizationLevel. Both of them will become unused because of the changes in requestAuthorization as described below.

  • __async requestAuthorization(authorizationLevel)__
    You must call this method with your desired permission level before requesting location, thus removing the necessity of skipPermissionRequests & authorizationLevel. Furthermore, this method now returns a promise which you can use to check the authorization status and take necessary actions.

    const status = await Geolocation.requestAuthorization("whenInUse"); // or "always"
    console.log(status); // "disabled", "granted", "denied", "restricted"
    
  • __getCurrentPosition()__
    Removed async keyword, since it's not an async function. Also removed useSignificantChanges option cause it's not needed for single location update.

Most helpful comment

iOS implementation is done, I'll merge this into master soon. If anyone has any suggestion or faced any issue, let me know.

All 5 comments

omg this is great!

iOS implementation is done, I'll merge this into master soon. If anyone has any suggestion or faced any issue, let me know.

Nice work! Just to double check, react-native-geolocation is no longer a dependency?

I wonder if there's any reason to use the "older" library at all now.

Thanks for your work @Agontuk, just to double what Cristiano has asked. Is the other dependency no longer a requirement for the iOS implementation?

No, react-native-geolocation dependency is removed in v5.0.0

Was this page helpful?
0 / 5 - 0 ratings