2017-10-26 9 views
1
// Create a location manager object 
self.locationManagerTest = [[CLLocationManager alloc] init]; 

// Set the delegate 
self.locationManagerTest.delegate = self; 

// Request location authorization 
[self.locationManagerTest requestAlwaysAuthorization]; 

// Specify the type of activity your app is currently performing 
self.locationManagerTest.activityType = CLActivityTypeOtherNavigation; 

// Start location updates 
[self.locationManagerTest startUpdatingLocation]; 

답변

1

1.after 2 주 도움이 희망을 애플 문서로 가야했습니다. 두 줄만 추가하면됩니다.

self.locationManagerTest = [[CLLocationManager alloc] init]; 
// Set the delegate 
self.locationManagerTest.delegate = self; 
// Request location authorization 
[self.locationManagerTest requestWhenInUseAuthorization]; 
// Set an accuracy level. The higher, the better for energy. 
self.locationManagerTest.desiredAccuracy = kCLLocationAccuracyThreeKilometers; 
// Enable automatic pausing 
self.locationManagerTest.pausesLocationUpdatesAutomatically = NO; 
// Specify the type of activity your app is currently performing 
self.locationManagerTest.activityType = CLActivityTypeFitness; 
// Enable background location updates 
self.locationManagerTest.allowsBackgroundLocationUpdates = YES; 
// Start location updates 
[self.locationManagerTest startUpdatingLocation]; 
1

/배경 모드/위치 업데이트 켜고의 Info.plist이 키 "개인 정보 보호 - 위치 항상 사용 설명"추가 최종적으로 해결이이 문제에 어려움을 겪고