CLLocationmanager setAuthorizationStatus不起作用(越狱)

我有6.1.3 iOS越狱设备。 另外我有命令行工具,应该给我坐标。 关于位置的代码与普通的应用程序完美地工作,而不是在命令行中。

我发现类似的问题,但它似乎并没有工作: 获取GPS没有警戒查看与ROOT权限(越狱)

- (void) start { NSLog(@"Started"); if ([CLLocationManager authorizationStatus] != kCLAuthorizationStatusAuthorized) { NSLog(@"%i", [CLLocationManager authorizationStatus]); } //[locationManager setAuthorizationStatus:YES forBundleIdentifier:[[NSBundle mainBundle] bundleIdentifier]]; [CLLocationManager setAuthorizationStatus:YES forBundleIdentifier:[[NSBundle mainBundle] bundleIdentifier]]; NSLog(@"%@", [[NSBundle mainBundle] bundleIdentifier]); NSLog(@"%@", [[NSBundle mainBundle] bundlePath]); if ([CLLocationManager authorizationStatus] != kCLAuthorizationStatusAuthorized) { NSLog(@"%i", [CLLocationManager authorizationStatus]); } [locationManager startUpdatingLocation]; 

}

所以它总是logging0作为授权状态= kCLAuthorizationStatusNotDetermined。

在构build完成之后,我还在ldid中添加了应用程序权利

 com.apple.locationd.authorizeapplications 

按键设置为真。 也有一些Info.plist的实验,但仍然

 didUpdatedLocation 

从不触发。

提前致谢!

这里是我的主要如果需要:

 #import <Foundation/Foundation.h> #import "locateClass.h" int main (int argc, const char * argv[]) { @autoreleasepool { // insert code here... NSLog(@"Hello, World!"); locateClass *loc = [[locateClass alloc] init]; [loc start]; } return 0; } 

另外我正在使用iOSOpenDev

更新:

如果我不使用Info.plist,使用这个代码,我在控制台中有这个:

 iPhone-AppServer Saimon[841] <Warning>: Hello, World! iPhone-AppServer Saimon[841] <Warning>: Started iPhone-AppServer Saimon[841] <Warning>: 1 iPhone-AppServer Saimon[841] <Warning>: (null) iPhone-AppServer Saimon[841] <Warning>: /private/var/mobile/docs/fromMac/Debug-iphoneos iPhone-AppServer Saimon[841] <Warning>: 1 iPhone-AppServer awdd[842] <Error>: libMobileGestalt copySystemVersionDictionaryValue: Could not lookup ReleaseType from system version dictionary iPhone-AppServer awdd[842] <Error>: CoreLocation: CLClient is deprecated. Will be obsolete soon. 

如果我这样做 – 这样的输出:

 iPhone-AppServer Saimon[854] <Warning>: Hello, World! iPhone-AppServer Saimon[854] <Warning>: Started iPhone-AppServer locationd[362] <Warning>: Launch Services: Registering unknown app identifier com.apple.xcode.dsym.Saimon failed iPhone-AppServer locationd[362] <Warning>: Launch Services: Unable to find app identifier com.apple.xcode.dsym.Saimon iPhone-AppServer Saimon[854] <Warning>: 0 iPhone-AppServer Saimon[854] <Warning>: com.apple.xcode.dsym.Saimon iPhone-AppServer Saimon[854] <Warning>: /private/var/mobile/docs/fromMac/Debug-iphoneos iPhone-AppServer Saimon[854] <Warning>: 0 iPhone-AppServer awdd[855] <Error>: libMobileGestalt copySystemVersionDictionaryValue: Could not lookup ReleaseType from system version dictionary iPhone-AppServer awdd[855] <Error>: CoreLocation: CLClient is deprecated. Will be obsolete soon. 

你如何加载info.plist? 因为它返回失败…

 Registering unknown app identifier com.apple.xcode.dsym.Saimon failed 

那么我发现不是那么容易的解决方法。

一步步。

要授权你自己停止定位过程,但是killall -9 locationd不会帮助你。 停止它: launchctl unload /System/Library/LaunchDaemons/com.apple.locationd.plist

然后在这个方法上编辑/var/root/Library/Caches/locationd/clients.plist文件:

 Root |__<your_bundleid> (Dictionary) |__Whitelisted (Boolean) - NO |__BundleId (String) - <yourBundleID> |__Authorized (Boolean) - YES |__Executable (String) - <path_to_your_binary> |__Registered (String) - <path_to_your_binary> 

然后开始定位:

 launchctl load /System/Library/LaunchDaemons/com.apple.locationd.plist 

之后这是可能的位置,但在命令行工具didUpdatedLocations方法不会触发,还有一个问题:大约一分钟后[CLLocationManager AuthenticationStatus]会给你拒绝状态,所以你需要再次手动编辑plist从你的TimeMissing词典中删除TimeMissing键。

这是自我注册后为我工作的代码:

 while (1){ CLLocationManager *locationManager = [[CLLocationManager alloc] init]; locationManager.desiredAccuracy = kCLLocationAccuracyBest; [locationManager startUpdatingLocation]; CLLocation *location = locationManager.location; if ([CLLocationManager authorizationStatus] != kCLAuthorizationStatusAuthorized) { NSLog(@"%i", [CLLocationManager authorizationStatus]); if( [CLLocationManager authorizationStatus] == 2) { system("ps ax | grep locationd"); system("launchctl unload /System/Library/LaunchDaemons/com.apple.locationd.plist"); NSString* plistPath = [[NSString alloc] initWithString:@"/var/root/Library/Caches/locationd/clients.plist"]; NSMutableDictionary* plist = [NSMutableDictionary dictionaryWithContentsOfFile: plistPath]; NSMutableDictionary *myBundle = [plist objectForKey:[[NSBundle mainBundle] bundleIdentifier]]; [myBundle removeObjectForKey:@"TimeMissing"]; NSLog(@"Relaunching"); [plist setObject:myBundle forKey:[[NSBundle mainBundle] bundleIdentifier]]; [plist writeToFile:@"/var/root/Library/Caches/locationd/clients.plist" atomically:YES]; system("launchctl load /System/Library/LaunchDaemons/com.apple.locationd.plist"); } } NSLog(@"Coordinates are %f %f %f %f", location.coordinate.latitude, location.coordinate.longitude, location.horizontalAccuracy, location.verticalAccuracy); if ( location.coordinate.latitude == 0 && location.coordinate.longitude == 0) { NSLog(@"Nulss"); system("launchctl unload /System/Library/LaunchDaemons/com.apple.locationd.plist"); system("launchctl load /System/Library/LaunchDaemons/com.apple.locationd.plist"); } else { NSLog(@"Got IT"); //[locationManager stopUpdatingLocation]; //break; } sleep(10); } 

在iOS6和iOS7上testing。