2017-12-20 7 views
0

Hallo habe Gerät aktuellen Standort abrufen und dafür verwende ich CLLocationManager-Klasse, aber didUpdateLocations nicht aufrufen.didUpdateLocations Delegate von CLLocationManager wird nicht in iOS 11 aufgerufen und Xcode 9.1

Ich bin

Mein Code und plist sind unten:

enter image description here

enter image description here

enter image description here

enter image description here

+0

'locationManger? .delegate = hinzufügen self' wird in' viewDidLoad' gesetzt? –

+0

@InderKumarRathore ja, aber wenn ich delegate in viewWillAppear dann immer noch nicht funktioniert. –

+0

Haben Sie vom Benutzer eine Position angefordert? 'locationManager.requestWhenInUseAuthorization()' oder 'locationManager.requestAlwaysAuthorization()' –

Antwort

1
<key>NSLocationAlwaysUsageDescription</key> 
    <string>Requires GPS to track persons</string> 
    <key>NSLocationAlwaysAndWhenInUseUsageDescription</key> 
    <string>Requires GPS to track persons</string> 
    <key>NSLocationWhenInUseUsageDescription</key> 
    <string>Requires GPS to track persons</string> 
    <key>UIBackgroundModes</key> 
    <array> 
     <string>fetch</string> 
     <string>location</string> 
    </array> 

dies in viewDidLoad

locationManager.delegate = self 
    self.locationManager.allowsBackgroundLocationUpdates = true 
    self.locationManager.startUpdatingLocation() 
+0

Ich habe diesen Code verwendet. Aber immer noch nicht funktioniert. –

+0

@ajeetsharma einmal die App löschen und wieder ausführen –

+0

danke !! seine Arbeit: D (y) –

Verwandte Themen