ios - 越狱检测

标签 ios objective-c xcode5 jailbreak

如果我想让应用程序运行命令来检查设备是否越狱,我该怎么做?

(如果程序可以确定是否安装了Cydia,这是我要执行的命令)

UIAlertView *jailbreakDetection = [[UIAlertView alloc]
                                   initWithTitle:@"Jailbreak Detected"
                                   message:@"This application will not run while a jailbreak is installed."
                                   delegate:nil
                                   cancelButtonTitle:nil
                                   otherButtonTitles:nil];

[jailbreakDetection show];

通过显示此警报,用户无法运行该应用程序,因为无法阻止该消息在屏幕上显示。我研究了一些类似的问题,但是没有一个对我有用,例如,当我运行这段代码时,出现错误“Expected identifier or'('”。我正在NavigationController.m文件中运行它,这样我就可以在首次启动应用程序时就击中用户。
NSString *filePath = @"/Applications/Cydia.app";

if ([[NSFileManager defaultManager] fileExistsAtPath:filePath])
{
UIAlertView *jailbreakDetection = [[UIAlertView alloc]
                                  initWithTitle:@"Jailbreak Detected"
                                  message:@"This application will not run while a jailbreak is installed."
                                  delegate:nil
                                  cancelButtonTitle:nil
                                  otherButtonTitles:nil];

 [jailbreakDetection show];
}

我在做什么错呢?我应该将其放在单独的文件中吗?

最佳答案

您的代码不是方法或函数的一部分,因此无法编译。
您必须移动该代码,例如到viewDidLoad

(此答案仅涉及编译器错误,而不涉及可能的机制
越狱检测)。

关于ios - 越狱检测,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20751677/

相关文章:

ios - Worklight 6.0.0.1 iOS native 库仅适用于 ARMv7 而不适用于 ARMv7s 和 ARM64?

ios - 使用尺寸适合时标签消失?

xcode - Xcode 中的这些黄色间隔是什么?

xcode5 - ios 8,如何使用ALAssetLibrary获取所有照片来替换丢失的相机胶卷相册

ios - Objective-c:为什么 Core Foundation 变量需要在 ARC 中显式释放?

带有 xcode 8 GM 的 iOS 10 GM 由于 roundedCorners 和 clipsToBounds 导致 View 消失

objective-c - 使用 Cocoascript 为 NSWindow 设置背景图像

ios - 如何在 GameOverScene 中从 GameViewController 调用方法

ios - 从增强现实开始

ios - 使形状的位置固定在 iOS 相机预览中