From f6fd8acd7c53c44187e70b4709443318a628f4b5 Mon Sep 17 00:00:00 2001 From: wxr <464027401@qq.com> Date: 星期二, 16 六月 2020 13:12:33 +0800 Subject: [PATCH] 2020-06-016 --- Shared.IOS/BaseApplicationDelegate.cs | 40 ++++++++++++++++++++++++++++++++++++---- 1 files changed, 36 insertions(+), 4 deletions(-) diff --git a/Shared.IOS/BaseApplicationDelegate.cs b/Shared.IOS/BaseApplicationDelegate.cs index 077856f..904144b 100644 --- a/Shared.IOS/BaseApplicationDelegate.cs +++ b/Shared.IOS/BaseApplicationDelegate.cs @@ -21,10 +21,42 @@ public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions) { registerForRemoteNotification(application); - var musicInfo = new MusicInfo { }; - Volume.Init(); + + if (Shared.Application.IsMusicEnable) + { + var musicInfo = new MusicInfo { }; + Volume.Init(); + } FinishedLaunchingAction?.Invoke(application, launchOptions); + + //GPS + if (Shared.Application.IsGpsEnable) + { + if (MyCLLocationManager.Instance.IsLocationServicesEnabled) + { + switch (Shared.Application.CurrentGpsUseMode) + { + case Application.GpsUseMode.Always: + MyCLLocationManager.Instance.RequestAlwaysAuthorization(); + break; + case Application.GpsUseMode.WhenInUse: + MyCLLocationManager.Instance.RequestWhenInUseAuthorization(); + break; + } + if (launchOptions != null && launchOptions.ObjectForKey(UIApplication.LaunchOptionsLocationKey) != null) + { + MyCLLocationManager.Instance.StartMonitoringSignificantLocationChanges(); + } + else + { + MyCLLocationManager.Instance.StartUpdatingLocation(); + } + } + else { + ///TODO 鍙互鎻愮ず鐢ㄦ埛鎵撳紑瀹氫綅鏉冮檺 + } + } return true; } @@ -61,7 +93,7 @@ locationManager = new MyCLLocationManager(); //璁剧疆鏄惁鍏佽绯荤粺鑷姩鏆傚仠瀹氫綅 locationManager.PausesLocationUpdatesAutomatically = false; - //locationManager.AllowsBackgroundLocationUpdates = true; + locationManager.AllowsBackgroundLocationUpdates = true; //璁剧疆瀹氫綅绮惧害 locationManager.DesiredAccuracy = CLLocation.AccuracyKilometer; locationManager.init(); @@ -93,7 +125,7 @@ { var location = e.Locations[e.Locations.Length - 1]; //adjustDistanceFilter(location); - System.Console.WriteLine($"浣嶇疆淇℃伅鍙樺寲 缁忓害{location.Coordinate.Longitude} 绾害{location.Coordinate.Latitude}"); + //Shared.HDLUtils.WriteLine($"浣嶇疆淇℃伅鍙樺寲 缁忓害{location.Coordinate.Longitude} 绾害{location.Coordinate.Latitude}"); uploadToServer(location); }; -- Gitblit v1.8.0