CLLocationmanager setAuthorizationStatus不起作用(越狱) [英] CLLocationmanager setAuthorizationStatus doesn't work (jailbreak)

查看:72
本文介绍了CLLocationmanager setAuthorizationStatus不起作用(越狱)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有使用6.1.3 iOS的越狱设备。我也有命令行工具,应该给我坐标。关于位置的代码可以在普通应用程序中正常运行,但不能在命令行中运行。

I have jailbroken device with 6.1.3 iOS. Also I have command-line tool that should give me coordinates. Code that is about location works perfectly with normal application, but not in command line.

我发现了类似的问题,但似乎不起作用:获得具有ROOT权限(jailbreak)的没有警报视图的GPS

I found similar question, but it doesn't seems to work: Get GPS without alert view with ROOT permission(jailbreak)

- (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];

}

因此它总是记录0作为授权状态= kCLAuthorizationStatusNotDetermined。

so it always log 0 as authorization status = kCLAuthorizationStatusNotDetermined.

我还使用

com.apple.locationd.authorizeapplications

键设置为true。也对Info.plist进行了一些实验,但仍然

key set true. also had some experiments with Info.plist, but still

didUpdatedLocation

永远不会触发。

谢谢!

如果需要,这是我的主要工具:

here is my main if needed:

#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

Also I'm using iOSOpenDev

更新:

如果我不使用Info.plist,则可以使用以下代码在控制台中找到它:

If I don't use Info.plist, With this code I have this in Console:

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.

如果我愿意-这样的输出:

If I do - such output:

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.


推荐答案

好吧,我发现解决方法不那么容易。

Well I found not so easy workaround.

分步进行。

要授权自己,您应该停止定位过程,但 killall -9位于不会对您有帮助。停止它: launchctl卸载/System/Library/LaunchDaemons/com.apple.locationd.plist

To authorize yourself you shuld stop locationd process, but killall -9 locationd won't help you. to stop it: launchctl unload /System/Library/LaunchDaemons/com.apple.locationd.plist

然后编辑/var/root/Library/Caches/locationd/clients.plist文件的方式如下:

Then edit /var/root/Library/Caches/locationd/clients.plist file on this way:

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并从bundleid词典中删除 TimeMissing 键。

After this it is possible to get the location, but in comand line tool didUpdatedLocations method doesn't trigger, and one more problem: after about a minute you [CLLocationManager AuthenticationStatus] will give you Denied status, so you need manually edit plist again and delete TimeMissing key from your bundleid dictionary.

以下是自我注册后对我有用的代码:

Here's the code worked for me after self registration:

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上进行了测试。

Tested on iOS6 and iOS7.

这篇关于CLLocationmanager setAuthorizationStatus不起作用(越狱)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆