Skip to content

Commit

Permalink
fix authorization callback issue
Browse files Browse the repository at this point in the history
  • Loading branch information
HarshaR1642 committed Oct 17, 2024
1 parent b879010 commit 4e338db
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 17 deletions.
12 changes: 2 additions & 10 deletions example/ios/ReactNativeGeofencingExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -598,11 +598,7 @@
"-DFOLLY_CFG_NO_COROUTINES=1",
"-DFOLLY_HAVE_CLOCK_GETTIME=1",
);
OTHER_LDFLAGS = (
"$(inherited)",
"-Wl",
"-ld_classic",
);
OTHER_LDFLAGS = "$(inherited)";
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
SDKROOT = iphoneos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) DEBUG";
Expand Down Expand Up @@ -675,11 +671,7 @@
"-DFOLLY_CFG_NO_COROUTINES=1",
"-DFOLLY_HAVE_CLOCK_GETTIME=1",
);
OTHER_LDFLAGS = (
"$(inherited)",
"-Wl",
"-ld_classic",
);
OTHER_LDFLAGS = "$(inherited)";
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
SDKROOT = iphoneos;
USE_HERMES = true;
Expand Down
9 changes: 3 additions & 6 deletions ios/Geofencing.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,6 @@ class Geofencing: RCTEventEmitter, CLLocationManagerDelegate {
return
}

if CLLocationManager.authorizationStatus() != .notDetermined {
successCallback([["success": true, "location": getLocationAuthorizationStatus()]])
return
}

self.allowWhileUsing = allowWhileUsing
self.allowAlways = allowAlways
authorizationSuccessCallback = successCallback
Expand Down Expand Up @@ -206,17 +201,19 @@ class Geofencing: RCTEventEmitter, CLLocationManagerDelegate {
if status == .authorizedAlways {
locationManager.allowsBackgroundLocationUpdates = true
authorizationSuccessCallback?([["success": true, "location": getLocationAuthorizationStatus()]])
authorizationSuccessCallback = nil
} else if status == .authorizedWhenInUse {
if self.allowAlways {
requestAlwaysAuthorization()
} else {
authorizationSuccessCallback?([["success": true, "location": getLocationAuthorizationStatus()]])
authorizationSuccessCallback = nil
}
} else {
authorizationSuccessCallback?([["success": false, "location": getLocationAuthorizationStatus()]])
authorizationSuccessCallback = nil
}

authorizationSuccessCallback = nil
}

private func isLocationAuthorized() -> Bool {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@rn-bridge/react-native-geofencing",
"version": "1.0.0",
"version": "1.0.1",
"description": "Native modules to determine if a location is within defined geographical boundaries",
"source": "./src/index.tsx",
"main": "./lib/commonjs/index.js",
Expand Down

0 comments on commit 4e338db

Please sign in to comment.