在iOS 9.3.1中获取位置权限后应用程序崩溃

时间:2022-07-10 01:26:49

Hi

I want to get user location, code works first time getting location in didUpdateLocations. But after few second app crashing.

我想获取用户位置,代码首次在didUpdateLocations中获取位置。但经过几秒钟的应用程序崩溃。

Crash is: 在iOS 9.3.1中获取位置权限后应用程序崩溃

Code I am using

我正在使用的代码

import UIKit
import CoreLocation

class HomeViewController: UIViewController, UIScrollViewDelegate ,UICollectionViewDataSource, UICollectionViewDelegate, CLLocationManagerDelegate  { 

// Location Manager
var locationManager: CLLocationManager = CLLocationManager()

//MARK: Location related functions
func trackLocation(){
    // Set the delegate
    self.locationManager.delegate = self

    // Request location authorization
    self.locationManager.requestWhenInUseAuthorization()

    // Request a location update
    if #available(iOS 9.0, *) {
        self.locationManager.requestLocation()
    } else {
        // Fallback on earlier versions
    }

    // Start location updates
    self.locationManager.startUpdatingLocation()

}

func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
    if let location = locations.first {
        print("Found user's location: \(location)")
    }
}

func locationManager(manager: CLLocationManager, didFailWithError error: NSError) {
    print("Failed to find user's location: \(error.localizedDescription)")
}

Plist 在iOS 9.3.1中获取位置权限后应用程序崩溃

Please let me what I missed

请告诉我我错过的

1 个解决方案

#1


1  

Found the issue, we are using webengage for notification and event tracking, issue was in it.

发现问题,我们正在使用webengage进行通知和事件跟踪,问题就在其中。

When I check with removing of it, code work fine.

当我检查删除它,代码工作正常。

I have contacted with webengage support, they have fixed this issue, so

我已经联系了webengage支持,他们已经解决了这个问题,所以

pod update

will fix this issue

将解决这个问题

#1


1  

Found the issue, we are using webengage for notification and event tracking, issue was in it.

发现问题,我们正在使用webengage进行通知和事件跟踪,问题就在其中。

When I check with removing of it, code work fine.

当我检查删除它,代码工作正常。

I have contacted with webengage support, they have fixed this issue, so

我已经联系了webengage支持,他们已经解决了这个问题,所以

pod update

will fix this issue

将解决这个问题