summaryrefslogtreecommitdiff
path: root/external/plyer/platforms/ios/gps.py
diff options
context:
space:
mode:
authorLivio Recchia <recchialivio@libero.it>2020-02-10 23:06:34 +0100
committerLivio Recchia <recchialivio@libero.it>2020-02-10 23:06:34 +0100
commit9a13903a2f7d3a65fdf15a65fb59cccd622e2066 (patch)
tree9403b7dff39eb5e5d7fa0f79efb69b496add4c4b /external/plyer/platforms/ios/gps.py
parent11cc316b74d5f3f283413a33e7693b314741aa4a (diff)
downloadmanachat-9a13903a2f7d3a65fdf15a65fb59cccd622e2066.tar.gz
manachat-9a13903a2f7d3a65fdf15a65fb59cccd622e2066.tar.bz2
manachat-9a13903a2f7d3a65fdf15a65fb59cccd622e2066.tar.xz
manachat-9a13903a2f7d3a65fdf15a65fb59cccd622e2066.zip
Initial commit
Diffstat (limited to 'external/plyer/platforms/ios/gps.py')
-rw-r--r--external/plyer/platforms/ios/gps.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/external/plyer/platforms/ios/gps.py b/external/plyer/platforms/ios/gps.py
new file mode 100644
index 0000000..4d6d665
--- /dev/null
+++ b/external/plyer/platforms/ios/gps.py
@@ -0,0 +1,45 @@
+'''
+iOS GPS
+-----------
+'''
+
+from pyobjus import autoclass, protocol
+from pyobjus.dylib_manager import load_framework
+from plyer.facades import GPS
+
+load_framework('/System/Library/Frameworks/CoreLocation.framework')
+CLLocationManager = autoclass('CLLocationManager')
+
+
+class IosGPS(GPS):
+ def _configure(self):
+ if not hasattr(self, '_location_manager'):
+ self._location_manager = CLLocationManager.alloc().init()
+
+ def _start(self):
+ self._location_manager.delegate = self
+
+ self._location_manager.requestWhenInUseAuthorization()
+ # NSLocationWhenInUseUsageDescription key must exist in Info.plist
+ # file. When the authorization prompt is displayed your app goes
+ # into pause mode and if your app doesn't support background mode
+ # it will crash.
+ self._location_manager.startUpdatingLocation()
+
+ def _stop(self):
+ self._location_manager.stopUpdatingLocation()
+
+ @protocol('CLLocationManagerDelegate')
+ def locationManager_didUpdateLocations_(self, manager, locations):
+ location = manager.location
+
+ self.on_location(
+ lat=location.coordinate.a,
+ lon=location.coordinate.b,
+ speed=location.speed,
+ bearing=location.course,
+ altitude=location.altitude)
+
+
+def instance():
+ return IosGPS()