@@ -31,25 +31,28 @@ yarn add react-native-location-settings-enabler
3131``` js
3232import LocationSettingsEnabler from " react-native-location-settings-enabler"
3333
34- const { PRIORITIES , useCheckSettings , requestResolutionSettings } = LocationSettingsEnabler
35- const { HIGH_ACCURACY } = PRIORITIES
36-
37- // Define configuration
38- const config = {
39- priority: HIGH_ACCURACY , // default BALANCED_POWER_ACCURACY
40- alwaysShow: true , // default false
41- needBle: false , // default false
42- }
43-
44- const req = () => requestResolutionSettings (config)
34+ const {
35+ PRIORITIES: { HIGH_ACCURACY },
36+ useLocationSettings ,
37+ } = LocationSettingsEnabler
4538
46- // React Native App Component
39+ // React Component
4740const App = () => {
48- // use hook to check location status
49- const enabled = useCheckSettings (config)
41+ const [enabled , requestResolution ] = useLocationSettings (
42+ {
43+ priority: HIGH_ACCURACY , // default BALANCED_POWER_ACCURACY
44+ alwaysShow: true , // default false
45+ needBle: true , // default false
46+ },
47+ false /* optional: default undefined */ ,
48+ )
5049
5150 return (
52- < View> {! enabled && < Button onPress= {req} title= " Request Resolution Location Settings" / > }< / View>
51+ < View>
52+ {! enabled && (
53+ < Button onPress= {requestResolution} title= " Request Resolution Location Settings" / >
54+ )}
55+ < / View>
5356 )
5457}
5558```
@@ -61,8 +64,11 @@ const App = () => {
6164``` js
6265import LocationSettingsEnabler from " react-native-location-settings-enabler"
6366
64- const { PRIORITIES , checkSettings , requestResolutionSettings } = LocationSettingsEnabler
65- const { HIGH_ACCURACY } = PRIORITIES
67+ const {
68+ PRIORITIES: { HIGH_ACCURACY },
69+ checkSettings ,
70+ requestResolutionSettings
71+ } = LocationSettingsEnabler
6672
6773// Adds a listener to be invoked when location settings checked using
6874// [checkSettings] or changed using [requestResolutionSettings]
@@ -141,45 +147,31 @@ Static object contain a list quality of service for location updates. If your ap
141147
142148### Methods
143149
144- > ### ` useCheckSettings ({ priority, alwaysShow, needBle }, initialSatus ?)`
150+ > ### ` useLocationSettings ({ priority, alwaysShow, needBle }, initialStatus ?)`
145151
146152``` js
147153import LocationSettingsEnabler from " react-native-location-settings-enabler"
148154
149- const { useCheckSettings , PRIORITIES } = LocationSettingsEnabler
150- const { HIGH_ACCURACY } = PRIORITIES
155+ const {
156+ useLocationSettings ,
157+ PRIORITIES: { HIGH_ACCURACY },
158+ } = LocationSettingsEnabler
151159
152- const enabled = useCheckSettings ({
160+ const [ enabled , requestResolution ] = useLocationSettings ({
153161 priority: HIGH_ACCURACY , // optional: default BALANCED_POWER_ACCURACY
154162 alwaysShow: true , // optional: default false
155163 needBle: true , // optional: default false
156164})
157165
158166console .log (` Location are ${ enabled ? " enabled" : " disabled" } ` )
159- ```
160-
161- Hook let you check if the user's device location is turned off / on.
162-
163- ---
164167
165- > ### ` useRequestResolutionSettings({ priority, alwaysShow, needBle }, initialSatus?) `
166-
167- ``` js
168- import LocationSettingsEnabler from " react-native-location-settings-enabler"
169-
170- const { useRequestResolutionSettings , PRIORITIES } = LocationSettingsEnabler
171- const { HIGH_ACCURACY } = PRIORITIES
172-
173- const enabled = useRequestResolutionSettings ({
174- priority: HIGH_ACCURACY , // optional: default BALANCED_POWER_ACCURACY
175- alwaysShow: true , // optional: default false
176- needBle: true , // optional: default false
177- })
178-
179- console .log (` Location are ${ enabled ? " enabled" : " disabled" } ` )
168+ // ...
169+ if (! enabled) {
170+ requestResolution ()
171+ }
180172```
181173
182- Hooks let display an activity where the user's can turn location 'on', only if location is already turned 'off '.
174+ Hook let you check the user's device location status 'on' / 'off' and method let you display an activity where they can turn location 'on '.
183175
184176---
185177
@@ -188,8 +180,10 @@ Hooks let display an activity where the user's can turn location 'on', only if l
188180``` js
189181import LocationSettingsEnabler from " react-native-location-settings-enabler"
190182
191- const { checkSettings , PRIORITIES } = LocationSettingsEnabler
192- const { HIGH_ACCURACY } = PRIORITIES
183+ const {
184+ checkSettings ,
185+ PRIORITIES: { HIGH_ACCURACY },
186+ } = LocationSettingsEnabler
193187
194188checkSettings ({
195189 priority: HIGH_ACCURACY , // optional: default BALANCED_POWER_ACCURACY
@@ -207,8 +201,10 @@ Checking if the user's device location is turned on / off.
207201``` js
208202import LocationSettingsEnabler from " react-native-location-settings-enabler"
209203
210- const { requestResolutionSettings , PRIORITIES } = LocationSettingsEnabler
211- const { HIGH_ACCURACY } = PRIORITIES
204+ const {
205+ requestResolutionSettings ,
206+ PRIORITIES: { HIGH_ACCURACY },
207+ } = LocationSettingsEnabler
212208
213209requestResolutionSettings ({
214210 priority: HIGH_ACCURACY , // optional: default BALANCED_POWER_ACCURACY
0 commit comments