React Native Android Location Services Dialog Box
Projects are now compiled using Android SDK 26
Dialog box colors can now be changed.
LocationServicesDialogBox.checkLocationServicesIsEnabled({
message: "<font color='#f1eb0a'>Use Location ?</font>",
ok: "YES",
cancel: "NO",
style: {
backgroundColor: '#87a9ea',
positiveButtonTextColor: '#ffffff',
positiveButtonBackgroundColor: '#5fba7d',
negativeButtonTextColor: '#ffffff',
negativeButtonBackgroundColor: '#ba5f5f'
}
})
providerListener: false, //true => Trigger "locationProviderStatusChange" listener when the location state changes
import { DeviceEventEmitter } from 'react-native';
DeviceEventEmitter.addListener('locationProviderStatusChange', function(status) { // only trigger when "providerListener" is enabled
console.log(status); // status => {enabled: false, status: "disabled"} or {enabled: true, status: "enabled"}
});
componentWillUnmount() {
LocationServicesDialogBox.stopListener(); // Stop the "locationProviderStatusChange" listener
}