Skip to content

Commit

Permalink
update code
Browse files Browse the repository at this point in the history
  • Loading branch information
HarshaR1642 committed Aug 26, 2024
1 parent c188d59 commit 7128655
Show file tree
Hide file tree
Showing 22 changed files with 423 additions and 14 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,3 @@ example/.yarn/*

# Turborepo
.turbo/

# generated by bob
lib/
4 changes: 2 additions & 2 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1237,7 +1237,7 @@ PODS:
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- Yoga
- react-native-geofencing (0.6.0):
- react-native-geofencing (0.9.0):
- DoubleConversion
- glog
- hermes-engine
Expand Down Expand Up @@ -1757,7 +1757,7 @@ SPEC CHECKSUMS:
React-logger: 0a81d1a40650bbdafb255fe4616edb83feed0ee9
React-Mapbuffer: b758bec0d9994c10a2841dfd5ec70673665fd3e2
React-microtasksnativemodule: f25dba9c8c3f8be0b3368d52b99abd6e381dee1d
react-native-geofencing: 8ae5d2d171423a4f6f6d91735440d6b42465debd
react-native-geofencing: 7b7538824a9e107120f60e85c7ba3933552f920d
React-nativeconfig: 7af2ccce165f86b233a9f9d63295f6207e62640e
React-NativeModulesApple: db1c1ee9dda26c9e58d824b4100fed83add82ae9
React-perflogger: 7c4e97b47d8bc58c03fad1a6b97d96181b59aa41
Expand Down
20 changes: 18 additions & 2 deletions ios/Geofencing.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class Geofencing: RCTEventEmitter, CLLocationManagerDelegate {
authorizationSuccessCallback = successCallback

if allowAlways && CLLocationManager.authorizationStatus() == .authorizedWhenInUse {
locationManager.requestAlwaysAuthorization()
requestAlwaysAuthorization()
} else {
locationManager.requestWhenInUseAuthorization()
}
Expand Down Expand Up @@ -203,7 +203,7 @@ class Geofencing: RCTEventEmitter, CLLocationManagerDelegate {
authorizationSuccessCallback?([["success": true, "location": getLocationAuthorizationStatus()]])
} else if status == .authorizedWhenInUse {
if self.allowAlways {
locationManager.requestAlwaysAuthorization()
requestAlwaysAuthorization()
} else {
authorizationSuccessCallback?([["success": true, "location": getLocationAuthorizationStatus()]])
}
Expand Down Expand Up @@ -240,5 +240,21 @@ class Geofencing: RCTEventEmitter, CLLocationManagerDelegate {
return message
}

private func requestAlwaysAuthorization() {
if isBackgroundLocationUpdatesEnabled() {
locationManager.requestAlwaysAuthorization()
} else {
authorizationSuccessCallback?([["success": false, "location": getLocationAuthorizationStatus(), "reason": "Location updates background mode is not enabled"]])
authorizationSuccessCallback = nil
}
}

private func isBackgroundLocationUpdatesEnabled() -> Bool {
if let backgroundModes = Bundle.main.object(forInfoDictionaryKey: "UIBackgroundModes") as? [String] {
return backgroundModes.contains("location")
}
return false
}

}

1 change: 1 addition & 0 deletions ios/Geofencing.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// Even if this is empty, this is needed for autolinking with your project
148 changes: 148 additions & 0 deletions lib/commonjs/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions lib/commonjs/index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions lib/commonjs/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"type":"commonjs"}
144 changes: 144 additions & 0 deletions lib/module/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 7128655

Please sign in to comment.