npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

rn-nitro-location-enabler

v1.3.0

Published

allows to enabled location in android

Downloads

36

Readme

📍 RnNitroLocationEnabler

npm version license platform React Native

A lightweight React Native module built with Nitro Modules that provides seamless location services management for Android applications. Check if location is enabled and request users to enable it with a beautiful native dialog.

✨ Features

  • 🔍 Check Location Status: Determine if location services are enabled on the device
  • 🎯 Request Location Enablement: Show native Android dialog to enable location services
  • 🚀 Built with Nitro Modules: High-performance, type-safe React Native module
  • 📱 Android Support: Comprehensive Android location services integration
  • 🔧 TypeScript Support: Full TypeScript definitions included
  • Promise-based API: Clean, modern async/await interface

📋 Requirements

  • react-native-nitro-modules ^0.29.8

🚀 Installation

npm install rn-nitro-location-enabler react-native-nitro-modules

or

yarn add rn-nitro-location-enabler react-native-nitro-modules

🔧 Setup

Android Configuration

Add the following permissions to your android/app/src/main/AndroidManifest.xml:

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

📖 Usage

Basic Example

import React, { useState, useEffect } from 'react';
import { View, Text, Button, Alert, StyleSheet } from 'react-native';
import { isLocationEnabled, requestLocationEnabled } from 'rn-nitro-location-enabler';

const LocationComponent = () => {
  const [locationEnabled, setLocationEnabled] = useState(false);

  useEffect(() => {
    // Check initial location status
    const checkLocation = async () => {
      const enabled = isLocationEnabled();
      setLocationEnabled(enabled);
    };
    checkLocation();
  }, []);

  const handleRequestLocation = async () => {
    try {
      const result = await requestLocationEnabled();
      setLocationEnabled(result);

      if (result) {
        Alert.alert('Success', 'Location services have been enabled!');
      } else {
        Alert.alert('Location Required', 'Please enable location services to use this feature.');
      }
    } catch (error) {
      Alert.alert('Error', 'Failed to request location services');
    }
  };

  return (
    <View style={styles.container}>
      <Text style={styles.status}>
        Location Services: {locationEnabled ? '✅ Enabled' : '❌ Disabled'}
      </Text>
      <Button
        title="Enable Location Services"
        onPress={handleRequestLocation}
        disabled={locationEnabled}
      />
    </View>
  );
};

const styles = StyleSheet.create({
  container: {
    padding: 20,
    alignItems: 'center',
  },
  status: {
    fontSize: 16,
    marginBottom: 20,
    fontWeight: 'bold',
  },
});

export default LocationComponent;

Advanced Usage with Error Handling

import {
  isLocationEnabled,
  requestLocationEnabled,
} from 'rn-nitro-location-enabler';

class LocationService {
  static async ensureLocationEnabled(): Promise<boolean> {
    // Check if location is already enabled
    if (isLocationEnabled()) {
      return true;
    }

    // Request user to enable location
    try {
      const enabled = await requestLocationEnabled();

      if (!enabled) {
        console.warn('User declined to enable location services');
        return false;
      }

      return true;
    } catch (error) {
      console.error('Error requesting location services:', error);
      return false;
    }
  }

  static async withLocation<T>(
    action: () => Promise<T>,
    fallback?: () => Promise<T>
  ): Promise<T> {
    const locationEnabled = await this.ensureLocationEnabled();

    if (!locationEnabled && fallback) {
      return fallback();
    }

    if (!locationEnabled) {
      throw new Error('Location services are required for this operation');
    }

    return action();
  }
}

// Usage
const fetchUserLocation = async () => {
  return await LocationService.withLocation(
    async () => {
      // Your location-dependent code here
      return { latitude: 0, longitude: 0 }; // Example
    },
    async () => {
      // Fallback when location is not available
      return { latitude: null, longitude: null };
    }
  );
};

📚 API Reference

isLocationEnabled(): boolean

Synchronously checks if location services are enabled on the device.

Returns: boolean - true if location services are enabled, false otherwise.

Example:

const enabled = isLocationEnabled();
console.log(`Location services are ${enabled ? 'enabled' : 'disabled'}`);

requestLocationEnabled(): Promise<boolean>

Shows the native Android dialog to request enabling location services.

Returns: Promise<boolean> - Resolves to true if user enabled location, false if declined.

Example:

const result = await requestLocationEnabled();
if (result) {
  // Location services are now enabled
  console.log('Location services enabled successfully');
} else {
  // User declined to enable location
  console.log('User declined to enable location services');
}

🎯 Use Cases

  • Location-based apps: Maps, navigation, ride-sharing, food delivery
  • Geofencing applications: Location-based reminders and notifications
  • Fitness apps: Track workouts and outdoor activities
  • Social apps: Find nearby friends or places
  • Emergency services: Quick access to user location

🔍 How It Works

This module uses Android's native location services APIs:

  1. Location Status Check: Uses LocationManager to check if location services are enabled
  2. Location Request Dialog: Uses Google Play Services SettingsClient to show the native location enablement dialog
  3. Result Handling: Properly handles user responses and activity lifecycle

🛠 Development

Running the Example App

# Install dependencies
yarn install

# Run the example app
yarn example android

Building from Source

# Build the module
yarn prepare

# Run tests
yarn test

# Type checking
yarn typecheck

# Linting
yarn lint

🤝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

Development Workflow

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Make your changes and test them in the example app
  4. Commit your changes: git commit -m 'Add amazing feature'
  5. Push to the branch: git push origin feature/amazing-feature
  6. Open a Pull Request

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🙏 Acknowledgments

📞 Support


Made with ❤️ by Yogesh Solanki