webyonet / react-native-android-location-services-dialog-box

React Native Android Location Services Dialog Box
MIT License
182 stars 50 forks source link

TypeError: Cannot read property 'checkLocationServicesIsEnabled' of undefined #39

Closed NamanAulakh closed 6 years ago

NamanAulakh commented 6 years ago

package.json: "react-native": "^0.51.0", "react-native-android-location-services-dialog-box": "^2.4.3",

Code:

LocationServicesDialogBox.checkLocationServicesIsEnabled({
          message:
            "<h2>Use Location ?</h2>This app wants to change your device settings:<br/><br/>Use GPS, Wi-Fi, and cell network for location<br/><br/><a href='#'>Learn more</a>",
          ok: 'YES',
          cancel: 'NO',
          enableHighAccuracy: true, // true => GPS AND NETWORK PROVIDER, false => ONLY GPS PROVIDER
          showDialog: true, // false => Opens the Location access page directly
          openLocationServices: true,
          // false => Directly catch method is called if location services are turned off
          preventOutSideTouch: false,
          // true => To prevent the location services popup from closing when it is clicked outside
          preventBackClick: false,
          // true=>To prevent the location services popup from closing when it is clicked back
        })
          .then(success => {
            // success => {alreadyEnabled: true, enabled: true, status: "enabled"}
            navigator.geolocation.getCurrentPosition(
              position => {
                const initialPosition = JSON.stringify(position)
                this.setState({ initialPosition })
              },
              error => console.log(error),
              { enableHighAccuracy: false, timeout: 20000, maximumAge: 1000 },
            )
          })
          .catch(error => {
            console.log(error.message)
          })
NamanAulakh commented 6 years ago

Solution: restart again.