{"id":13776671,"url":"https://github.com/Richou/react-native-android-location-enabler","last_synced_at":"2025-05-11T10:31:15.692Z","repository":{"id":38953847,"uuid":"75670064","full_name":"Richou/react-native-android-location-enabler","owner":"Richou","description":"Display a GoogleMap like android popup to ask for user to enable location services if disabled","archived":false,"fork":false,"pushed_at":"2024-07-06T21:31:12.000Z","size":7574,"stargazers_count":212,"open_issues_count":34,"forks_count":51,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-05-03T23:47:02.766Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Richou.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-12-05T21:58:55.000Z","updated_at":"2025-02-26T03:08:54.000Z","dependencies_parsed_at":"2024-01-13T07:26:50.581Z","dependency_job_id":"35435464-78f7-4940-b387-8142f14e5b48","html_url":"https://github.com/Richou/react-native-android-location-enabler","commit_stats":{"total_commits":58,"total_committers":10,"mean_commits":5.8,"dds":"0.43103448275862066","last_synced_commit":"285460c51d79119ed4bd8f0fa98be91ddd320c89"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Richou%2Freact-native-android-location-enabler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Richou%2Freact-native-android-location-enabler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Richou%2Freact-native-android-location-enabler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Richou%2Freact-native-android-location-enabler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Richou","download_url":"https://codeload.github.com/Richou/react-native-android-location-enabler/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253551659,"owners_count":21926330,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T18:00:31.340Z","updated_at":"2025-05-11T10:31:11.827Z","avatar_url":"https://github.com/Richou.png","language":"Java","funding_links":[],"categories":["\u003ca name=\"Alter,-Prompt,-Action-\u0026-Dialog:-Native-Modules\"\u003eAlter, Prompt, Action \u0026 Dialog: Native Modules\u003c/a\u003e"],"sub_categories":[],"readme":"# react-native-android-location-enabler\n\nAllow to display a GoogleMap like android popup to ask for user to enable location services if disabled\n\n\u003cimg src=\"assets/android-location-enabler.gif\" width=\"360\" alt=\"See in action\" title=\"See component in action !\" \u003e\n\n## Getting started\n\n**ReactNative \u003e= 0.60.0**\n\n### Installation\n\n`$ npm install react-native-android-location-enabler --save`\n\nSince ReactNative 0.60.0 and ReactNative Cli 2.0.0, no action is needed to add a native module.\n\n**ReactNative \u003c 0.60.0**\n\n### Installation\n\n`$ npm install react-native-android-location-enabler@1.1.0 --save`\n\n#### Configuration\n\n`$ react-native link react-native-android-location-enabler`\n\n#### Manual Configuration\n\n1. Open up `android/app/src/main/java/[...]/MainApplication.java`\n\n- Add `import com.heanoria.library.reactnative.locationenabler.RNAndroidLocationEnablerPackage;` to the imports at the top of the file\n- Add `new RNAndroidLocationEnablerPackage()` to the list returned by the `getPackages()` method\n\n2. Append the following lines to `android/settings.gradle`:\n   ```\n   include ':react-native-android-location-enabler'\n   project(':react-native-android-location-enabler').projectDir = new File(rootProject.projectDir, \t'../node_modules/react-native-android-location-enabler/android')\n   ```\n3. Insert the following lines inside the dependencies block in `android/app/build.gradle`:\n   ```\n     compile project(':react-native-android-location-enabler')\n   ```\n\n## Usage\n\n### Check if location is enabled\n\n```typescript\nimport { isLocationEnabled } from 'react-native-android-location-enabler';\nimport { Platform } from 'react-native';\n\nasync function handleCheckPressed() {\n  if (Platform.OS === 'android') {\n    const checkEnabled: boolean = await isLocationEnabled();\n    console.log('checkEnabled', checkEnabled)\n  }\n}\n```\n\n### Show a modal to ask user to enable location\n\n```typescript\nimport { promptForEnableLocationIfNeeded } from 'react-native-android-location-enabler';\nimport { Platform } from 'react-native';\n\nasync function handleEnabledPressed() {\n  if (Platform.OS === 'android') {\n    try {\n      const enableResult = await promptForEnableLocationIfNeeded();\n      console.log('enableResult', enableResult);\n      // The user has accepted to enable the location services\n      // data can be :\n      //  - \"already-enabled\" if the location services has been already enabled\n      //  - \"enabled\" if user has clicked on OK button in the popup\n    } catch (error: unknown) {\n      if (error instanceof Error) {\n        console.error(error.message);\n        // The user has not accepted to enable the location services or something went wrong during the process\n        // \"err\" : { \"code\" : \"ERR00|ERR01|ERR02|ERR03\", \"message\" : \"message\"}\n        // codes :\n        //  - ERR00 : The user has clicked on Cancel button in the popup\n        //  - ERR01 : If the Settings change are unavailable\n        //  - ERR02 : If the popup has failed to open\n        //  - ERR03 : Internal error\n      }\n    }\n  }\n}\n```\n\n## Contributing\n\nSee the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.\n\n## License\n\nMIT\n\n---\n\nMade with [create-react-native-library](https://github.com/callstack/react-native-builder-bob)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FRichou%2Freact-native-android-location-enabler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FRichou%2Freact-native-android-location-enabler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FRichou%2Freact-native-android-location-enabler/lists"}