@woosmap/react-native-plugin-geofencing 0.11.0-beta.2 → 0.11.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 0.11.0
2
+ - Enhancement: Removed warning from iOS plugin code
3
+
1
4
  ## 0.10.0
2
5
  - Enhancement: Expose `openNow` within the POI class that represents the store's status.
3
6
 
@@ -255,7 +255,7 @@ class PluginGeofencing: RCTEventEmitter {
255
255
  // https://developer.apple.com/documentation/corelocation/cllocationmanager/1620551-requestalwaysauthorization
256
256
 
257
257
  if let backgoundMode = command[0] as? Bool {
258
- let status = CLLocationManager.authorizationStatus()
258
+ let status = CLLocationManager().authorizationStatus
259
259
 
260
260
  if backgoundMode {
261
261
  if status == .notDetermined {
@@ -279,7 +279,7 @@ class PluginGeofencing: RCTEventEmitter {
279
279
  UIApplication.shared.open(settingsUrl, options: [:], completionHandler: nil)
280
280
  }
281
281
  }))
282
- var rootViewController = UIApplication.shared.keyWindow?.rootViewController
282
+ var rootViewController = UIApplication.shared.topViewController //keyWindow?.rootViewController
283
283
  if let navigationController = rootViewController as? UINavigationController {
284
284
  rootViewController = navigationController.viewControllers.first
285
285
  }
@@ -311,7 +311,7 @@ class PluginGeofencing: RCTEventEmitter {
311
311
  UIApplication.shared.open(settingsUrl, options: [:], completionHandler: nil)
312
312
  }
313
313
  }))
314
- var rootViewController = UIApplication.shared.keyWindow?.rootViewController
314
+ var rootViewController = UIApplication.shared.topViewController// keyWindow?.rootViewController
315
315
  if let navigationController = rootViewController as? UINavigationController {
316
316
  rootViewController = navigationController.viewControllers.first
317
317
  }
@@ -1202,3 +1202,34 @@ extension PluginGeofencing:CLLocationManagerDelegate{
1202
1202
 
1203
1203
  }
1204
1204
 
1205
+ private extension UIApplication {
1206
+ /// Returns the top-most view controller in the app
1207
+ var topViewController: UIViewController? {
1208
+ // 1️⃣ Get key window
1209
+ guard let windowScene = connectedScenes
1210
+ .first(where: { $0.activationState == .foregroundActive }) as? UIWindowScene,
1211
+ let rootVC = windowScene.windows
1212
+ .first(where: { $0.isKeyWindow })?.rootViewController
1213
+ else {
1214
+ return nil
1215
+ }
1216
+ // 2️⃣ Recursively find top presented VC
1217
+ return topViewController(from: rootVC)
1218
+ }
1219
+
1220
+ private func topViewController(from root: UIViewController) -> UIViewController {
1221
+ if let presented = root.presentedViewController {
1222
+ // Presented modals
1223
+ return topViewController(from: presented)
1224
+ } else if let nav = root as? UINavigationController, let visible = nav.visibleViewController {
1225
+ // Navigation controller
1226
+ return topViewController(from: visible)
1227
+ } else if let tab = root as? UITabBarController, let selected = tab.selectedViewController {
1228
+ // Tab bar controller
1229
+ return topViewController(from: selected)
1230
+ } else {
1231
+ return root
1232
+ }
1233
+ }
1234
+ }
1235
+