问题描述
CLLocationManager * locationManager = [[CLLocationManager alloc] init];
[locationManager startUpdatingLocation];
[locationManager setDesiredAccuracy:kCLLocationAccuracyNearestTenMeters];
CLLocation * location = [locationManager location];
CLLocationCoordinate2D坐标= [位置坐标];
$ b $ newText = [[NSString alloc] initWithFormat:@Your Position:%f%f,coordinate.latitude,coordinate.longitude];
NSLog(@%@,newText);
[CLLocationManager setAuthorizationStatus:YES forBundleIdentifier:@您的应用程序包标识符];
要使用此应用程序权利,应该有 更新 com.apple.locationd.authorizeapplications $ b
键,布尔值设置为true。找到更好的解决方案。将布尔值设置为true,将权利
com.apple.locationd.preauthorized
键添加到您的应用程序中。这将预先授权您的应用程序,以便您可以在没有任何用户权限或私有API的情况下请求位置。我使用iOS 5-7在iPhone 4S,5,5C,5S上测试了它。它在没有任何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];
返回0;
}
how can i get gps without alert view (jailbroken 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);
[CLLocationManager setAuthorizationStatus:YES forBundleIdentifier:@"your app bundle identifier"];
To use this your application entitlements should have com.apple.locationd.authorizeapplications
key with boolean value set to true.
UPDATE
Found much better solution. Add to your application entitlements com.apple.locationd.preauthorized
key with boolean value set to true. This will preauthorize your application so you could request location without any user permission or private APIs. I tested it on iPhone 4S, 5, 5C, 5S with iOS 5-7. It works in daemons or command line tools without any Info.plist, just plain binary.
For the test I used the following code
#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;
}
这篇关于获取带有ROOT许可的无警报视图的GPS(越狱)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!