没有越狱检测

我正在试图制作一个应用程序,它只能在越狱的iDevices上运行。 我已经做了越狱检测:

([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"cydia://"]]);{ UIAlertView *cydiaisinstalled=[[UIAlertView alloc]initWithTitle:@"Cydia is installed!" message:@"You can use Respring!" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; [cydiaisinstalled show]; }} 

但现在我需要相反的东西。 我需要一个非JAILBREAK检测。

我需要你的帮助我需要这个Weblin。 请帮帮我!!!

尝试访问应用程序沙箱外的任何文件。 例如:

 BOOL IsDeviceJailbroken(void) { #if TARGET_IPHONE_SIMULATOR return NO; #else return [[NSFileManager defaultManager] fileExistsAtPath: @"/bin/bash"]; #endif } 

请注意,安装Cydia并安装越狱设备是两件不同的事情。

我写了一个function,检测设备是否越狱的另一个问题,但在这里似乎相关:

 - (BOOL) isJailbroken() { //If the app is running on the simulator #if TARGET_IPHONE_SIMULATOR return NO; //If its running on an actual device #else BOOL isJailbroken = NO; //This line checks for the existence of Cydia BOOL cydiaInstalled = [[NSFileManager defaultManager] fileExistsAtPath:@"/Applications/Cydia.app"]; FILE *f = fopen("/bin/bash", "r"); if (!(errno == ENOENT) || cydiaInstalled) { //Device is jailbroken isJailbroken = YES; } fclose(f); return isJailbroken; #endif } 

此function使用两个检查来查看手机是否越狱:它首先检查是否安装了Cydia。 并不是所有的越狱设备都安装了Cydia,尽pipe大多数都使用了,所以我也检查了bash的存在,它也只出现在越狱设备上。 请注意,这个函数几乎可以在所有情况下工作,但可能不是100%。 唯一没有Cydia越狱的人可能是那些正在尝试越狱设备,而不是使用他们的好处,如调整和主题。

好的,谢谢所有的答案,但我自己发现了。 这里是代码:

 if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"cydia://"]]) { //insert action if cydia is installed } if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"cydia://"]] == NO) { //insert action if Cydia is not installed } 

有了这个代码,你可以检测到你的idevice上的任何应用程序,只要该应用程序有一个URLscheme,你可以在这里find大部分的URLscheme: http : //handleopenurl.com

PS:你必须更换你的行为的绿色部分:)