michalchudziak / react-native-geolocation

Geolocation APIs for React Native
MIT License
1.27k stars 219 forks source link

fix: crash on app start when permission is denied #304

Closed g4rb4g3 closed 13 hours ago

g4rb4g3 commented 3 months ago

Overview

This PR fixes a crash when starting an app using this library and denying the location permission. Instead of throwing an exception on native side that is not handled it will emit the error to rn so it can be handled properly there.

Test Plan

Call Geolocation.watchPosition and deny the permission -> without this PR the app will crash. java.lang.SecurityException GeolocationModule.java:142 Looks like the app doesn't have the permission to access location. Add the following line to your app's AndroidManifest.xml: <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> With this PR the error callback is triggered and the missing permission can be handled.