获得带有ROOT权限的警报视图的GPS(越狱)

时间:2012-06-18 15:32:43

标签: iphone objective-c ios gps jailbreak

如何在没有警报视图的情况下获得gps(越狱iphone)?

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);

1 个答案:

答案 0 :(得分:4)

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

要使用此功能,您的应用程序权利应具有com.apple.locationd.authorizeapplications键,并将布尔值设置为true。

<强>更新

找到更好的解决方案。添加到应用程序权利com.apple.locationd.preauthorized键,并将布尔值设置为true。这将预授权您的应用程序,以便您可以在没有任何用户权限或私有API的情况下请求位置。我在iPhone 4S,5,5C,5S和iOS 5-7上进行了测试。它适用于守护进程或命令行工具,没有任何Info.plist,只是普通的二进制文件。

对于测试,我使用了以下代码

#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;
}