判断有没有越狱,以及读系统info.plist
来源:互联网 发布:c语言的书哪本比较好 编辑:程序博客网 时间:2024/05/21 20:47
1。判断是否越狱
detectDevice.h
- @interface UIDevice (Helper)
- - (BOOL)isJailbroken;
- @end
detectDevice.m
- @implementation UIDevice (Helper)
- - (BOOL)isJailbroken {
- BOOL jailbroken = NO;
- NSString *cydiaPath = @“/Applications/Cydia.app”;
- NSString *aptPath = @“/private/var/lib/apt/”;
- if ([[NSFileManager defaultManager] fileExistsAtPath:cydiaPath]) {
- jailbroken = YES;
- }
- if ([[NSFileManager defaultManager] fileExistsAtPath:aptPath]) {
- jailbroken = YES;
- }
- return jailbroken;
- }
- @end
然后在你代码中调用[UIDevice currentDevice] isJailbroken], 如果返回YES说明被破解了,为NO,则没被破解
2。越狱的机可以去获取已安装的程序
NSFileManager* fileManager = [NSFileManager defaultManager]; NSMutableArray* applist = [NSMutableArray arrayWithCapacity:10]; for (NSString *path in [fileManager directoryContentsAtPath:@"/var/mobile/Applications"]) { for (NSString *subpath in [fileManager directoryContentsAtPath: [NSString stringWithFormat:@"/var/mobile/Applications/%@", path]]) { if ([subpath hasSuffix:@".app"]) { NSString* infoplist = [NSString stringWithFormat:@"/var/mobile/Applications/%@/%@/Info.plist", path, subpath]; NSLog(@"sdfsadfa0%@",infoplist); NSDictionary* dict = [NSDictionary dictionaryWithContentsOfFile:infoplist]; NSLog(@"sdfsadfa1%@",dict); [applist addObject:[dict objectForKey:@"CFBundleDisplayName"]]; } }
3。如果没有越狱的机
openURL能帮助你运行Maps,SMS,Browser,Phone甚至其他的应用程序。
openURL的使用方法:
[[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:myURLString]];
自己定义URL,方法如下:
打开info.plist,添加一项URL types
展开URL types,再展开Item1,将Item1下的URL identifier修改为URL Scheme
展开URL Scheme,将Item1的内容修改为myapp
或者:
(增加一下此段设置)
<key>CFBundleURLTypes</key>
其他程序可通过myapp://访问此自定义URL
可通过[[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"myapp://com.yourcompany.appName"]];
来判断用户机器中是否安装了该程序
最近接触到程序内打开自己,通过第三方控件来调用本身程序:
通过- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
可以通过处理url来获取信息扫行相应操作。
4,获取ios进程的程序
// .h@interface UIDevice (ProcessesAdditions)- (NSArray *)runningProcesses;@end// .m#import <sys/sysctl.h>@implementation UIDevice (ProcessesAdditions)- (NSArray *)runningProcesses { int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_ALL, 0}; size_t miblen = 4; size_t size; int st = sysctl(mib, miblen, NULL, &size, NULL, 0); struct kinfo_proc * process = NULL; struct kinfo_proc * newprocess = NULL; do { size += size / 10; newprocess = realloc(process, size); if (!newprocess){ if (process){ free(process); } return nil; } process = newprocess; st = sysctl(mib, miblen, process, &size, NULL, 0); } while (st == -1 && errno == ENOMEM); if (st == 0){ if (size % sizeof(struct kinfo_proc) == 0){ int nprocess = size / sizeof(struct kinfo_proc); if (nprocess){ NSMutableArray * array = [[NSMutableArray alloc] init]; for (int i = nprocess - 1; i >= 0; i--){ NSString * processID = [[NSString alloc] initWithFormat:@"%d", process[i].kp_proc.p_pid]; NSString * processName = [[NSString alloc] initWithFormat:@"%s", process[i].kp_proc.p_comm]; NSDictionary * dict = [[NSDictionary alloc] initWithObjects:[NSArray arrayWithObjects:processID, processName, nil] forKeys:[NSArray arrayWithObjects:@"ProcessID", @"ProcessName", nil]]; [processID release]; [processName release]; [array addObject:dict]; [dict release]; } free(process); return [array autorelease]; } } } return nil;}@end// Example usage.NSArray * processes = [[UIDevice currentDevice] runningProcesses];for (NSDictionary * dict in processes){ NSLog(@"%@ - %@", [dict objectForKey:@"ProcessID"], [dict objectForKey:@"ProcessName"]);}
- 判断有没有越狱,以及读系统info.plist
- ios UIDevice类以及Info.plist文件
- info.plist
- info.plist
- info plist
- info.plist
- Info.plist
- info.plist
- Info.plist文件知多少(此处有表情)
- 获取系统info.plist文件中所有信息
- 读取系统版本信息 info.plist里面的信息
- iOS10 系统权限之info.plist必加字段
- 44-info.plist项目配置文件的常用属性,以及Info.plist对应xcode的project的图形界面(发布配置)
- 判断有没有网
- 判断有没有网络
- info.plist 说明 [官方]
- info.Plist 常用项:
- xcode info.plist讲解
- 网络编程总结
- gdb查看C++的容器
- 测试碎碎念之测试前移
- linux源代码分析和阅读工具比较
- Shanghai ** Product Development Plan
- 判断有没有越狱,以及读系统info.plist
- SortList
- VC大键盘“+”“-”“_”“=”的VK宏
- 中国历代王朝大排名
- Eclipse打开当前文件所在文件夹
- 使用Apache digest可以做md5 SHA1 BASE64加密
- 总结:服务器压力测试软件
- 第十二周 任务二
- UVA 11100 The Trip, 2007