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

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

Error implementing on React Native #67

Closed javadoh closed 5 years ago

javadoh commented 5 years ago

Error: [TypeError: undefined is not an object (evaluating '_reactNativeAndroidLocationServicesDialogBox.default.checkLocationServicesIsEnabled')]

Code:

import React, { Component } from 'react; import { StyleSheet, Text, View, Animated, Image, Dimensions, Alert, TouchableOpacity, Platform, BackHandler, DeviceEventEmitter } from "react-native"; import LocationServicesDialogBox from "react-native-android-location-services-dialog-box";


if (Platform.OS === 'android') {

  LocationServicesDialogBox.checkLocationServicesIsEnabled({
  message: "<h2 style='color: #0af13e'>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 => GPS OR NETWORK 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 window from closing when it is clicked outside
  preventBackClick: false, // true => To prevent the location services popup from closing when it is clicked back button
  providerListener: false // true ==> Trigger locationProviderStatusChange listener when the location state changes
  }).then(function(success) {
      console.log(success); // success => {alreadyEnabled: false, enabled: true, status: "enabled"}
  }).catch((error) => {
      console.log(error.message); // error.message => "disabled"
  });
}
webyonet commented 5 years ago

-- restart your PC or MAC (for background process) -- uninstall your app on mobile device

folow the steps below at the terminal step by step :

1) react-native unlink react-native-android-location-services-dialog-box
2) npm uninstall react-native-android-location-services-dialog-box
3) npm install react-native-android-location-services-dialog-box --save
4) react-native link react-native-android-location-services-dialog-box
5) react-native run-android
narek11 commented 5 years ago

@javadoh above steps worked for you?