获取GPS没有警报视图与ROOT权限(越狱)

我怎样才能没有警报视图(越狱iPhone)的GPS?

NSString *newText; CLLocationManager * locationManager = [[CLLocationManager alloc] init]; [locationManager startUpdatingLocation]; [locationManager setDesiredAccuracy:kCLLocationAccuracyNearestTenMeters]; CLLocation* location = [locationManager location]; CLLocationCoordinate2D coordinate = [location coordinate]; newText = [[NSString alloc] initWithFormat: @"Your Position : %f %f", coordinate.latitude, coordinate.longitude]; NSLog(@"%@", newText); 

 [CLLocationManager setAuthorizationStatus:YES forBundleIdentifier:@"your app bundle identifier"]; 

为了使用它,你的应用程序授权应该有com.apple.locationd.authorizeapplications键,布尔值设置为true。

UPDATE

find更好的解决scheme。 将布尔值设置为true的应用程序中的权利com.apple.locationd.preauthorized键添加到您的应用程序。 这将预先授权您的应用程序,以便您可以在没有任何用户权限或私有API的情况下请求位置。 我使用iOS 5-7在iPhone 4S,5,5C,5S上进行了testing。 它在没有任何Info.plist的守护进程或命令行工具中工作,只是简单的二进制。

为了testing,我使用了下面的代码

 #import <CoreLocation/CoreLocation.h> @interface LocationDelegate : NSObject<CLLocationManagerDelegate> @end @implementation -(void)locationManager:(CLLocationManager*)manager didUpdateLocations:(NSArray*)locations { NSLog(@"%@", locations); } @end int main(int argc, char * argv[]) { LocationDelegate* delegate = [[LocationDelegate alloc] init]; CLLocationManager* manager = [[CLLocationManager alloc] init]; manager.delegate = delegate; [manager startUpdatingLocation]; [[NSRunLoop currentRunLoop] run]; return 0; }