小编nil*_*nil的帖子

iOS 15 应用程序未在位置更改时处于终止状态启动

我在我的应用程序SS中添加了位置背景模式

但该应用程序仍然无法使用启动选项键启动

UIApplication.LaunchOptionsKey.location

这是我的应用程序委托代码,

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    // Override point for customization after application launch.
    addItem(name: "LaunchOptions: \(String(describing: launchOptions))")
    if let launchOptions = launchOptions {
        if launchOptions[UIApplication.LaunchOptionsKey.location] != nil {
            startLocationMonitoring()
        }
    }
    print("LaunchOptions: \(String(describing: launchOptions))")
    return true
}

func startLocationMonitoring() {
    locationManager?.delegate = nil
    locationManager = nil
    locationManager = CLLocationManager()
    locationManager?.delegate = self
    locationManager?.desiredAccuracy = kCLLocationAccuracyBestForNavigation
    locationManager?.distanceFilter = 1.0 // meters
    locationManager?.allowsBackgroundLocationUpdates = true
    locationManager?.activityType = .otherNavigation
    locationManager?.pausesLocationUpdatesAutomatically = false …
Run Code Online (Sandbox Code Playgroud)

gps location appdelegate swift ios15

8
推荐指数
1
解决办法
734
查看次数

标签 统计

appdelegate ×1

gps ×1

ios15 ×1

location ×1

swift ×1