Security News
PyPI’s New Archival Feature Closes a Major Security Gap
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
react-native-android-location-enabler
Advanced tools
Display a GoogleMap like android popup to ask for user to enable location services if disabled
Allow to display a GoogleMap like android popup to ask for user to enable location services if disabled
ReactNative >= 0.60.0
$ npm install react-native-android-location-enabler --save
Since ReactNative 0.60.0 and ReactNative Cli 2.0.0, no action is needed to add a native module.
ReactNative < 0.60.0
$ npm install react-native-android-location-enabler@1.1.0 --save
$ react-native link react-native-android-location-enabler
android/app/src/main/java/[...]/MainApplication.java
import com.heanoria.library.reactnative.locationenabler.RNAndroidLocationEnablerPackage;
to the imports at the top of the filenew RNAndroidLocationEnablerPackage()
to the list returned by the getPackages()
methodandroid/settings.gradle
:
include ':react-native-android-location-enabler'
project(':react-native-android-location-enabler').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-android-location-enabler/android')
android/app/build.gradle
:
compile project(':react-native-android-location-enabler')
import { isLocationEnabled } from 'react-native-android-location-enabler';
import { Platform } from 'react-native';
async function handleCheckPressed() {
if (Platform.OS === 'android') {
const checkEnabled: boolean = await isLocationEnabled();
console.log('checkEnabled', checkEnabled)
}
}
import { promptForEnableLocationIfNeeded } from 'react-native-android-location-enabler';
import { Platform } from 'react-native';
async function handleEnabledPressed() {
if (Platform.OS === 'android') {
try {
const enableResult = await promptForEnableLocationIfNeeded();
console.log('enableResult', enableResult);
// The user has accepted to enable the location services
// data can be :
// - "already-enabled" if the location services has been already enabled
// - "enabled" if user has clicked on OK button in the popup
} catch (error: unknown) {
if (error instanceof Error) {
console.error(error.message);
// The user has not accepted to enable the location services or something went wrong during the process
// "err" : { "code" : "ERR00|ERR01|ERR02|ERR03", "message" : "message"}
// codes :
// - ERR00 : The user has clicked on Cancel button in the popup
// - ERR01 : If the Settings change are unavailable
// - ERR02 : If the popup has failed to open
// - ERR03 : Internal error
}
}
}
}
See the contributing guide to learn how to contribute to the repository and the development workflow.
MIT
Made with create-react-native-library
FAQs
Display a GoogleMap like android popup to ask for user to enable location services if disabled
The npm package react-native-android-location-enabler receives a total of 91,343 weekly downloads. As such, react-native-android-location-enabler popularity was classified as popular.
We found that react-native-android-location-enabler demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
Research
Security News
Malicious npm package postcss-optimizer delivers BeaverTail malware, targeting developer systems; similarities to past campaigns suggest a North Korean connection.
Security News
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.