判断有没有越狱,以及读系统info.plist
2012-05-09 12:32
369 查看
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。越狱的机可以去获取已安装的程序
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>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>myapp</string>
</array>
<key>CFBundleURLName</key>
<string>com.yourcompany.appName</string>
</dict>
</array>
其他程序可通过myapp://访问此自定义URL
可通过[[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"myapp://com.yourcompany.appName"]];
来判断用户机器中是否安装了该程序
最近接触到程序内打开自己,通过第三方控件来调用本身程序:
通过- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
可以通过处理url来获取信息扫行相应操作。
4,获取ios进程的程序
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>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>myapp</string>
</array>
<key>CFBundleURLName</key>
<string>com.yourcompany.appName</string>
</dict>
</array>
其他程序可通过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"]); }
相关文章推荐
- MySQL 条件判断函数以及一些常用系统函数
- 44-info.plist项目配置文件的常用属性,以及Info.plist对应xcode的project的图形界面(发布配置)
- 关于大小端的简单介绍以及使用C写一个函数判断当前系统是大端存储还是小端存储
- 用&nbsp;systeminfo&nbsp;命令判断系统是32位…
- OSX: 判断用户/系统的所属域以及LKDC
- OSX: 判断用户/系统的所属域以及LKDC
- JAVA的系统时间输出以及判断今天是星期几
- js以及php判断安卓系统和ios系统
- iOS10 系统权限之info.plist必加字段
- iOS 判断系统是否越狱的代码
- IOS 获取IDFA以及判断是否越狱
- bat批处理判断系统32位或64位以及操作系统类型
- JAVA的系统时间输出以及判断今天是星期几
- Android 双击以及连续多次点击事件系统自带判断方法
- (4.2.16.3)判断某Activity是否在系统中存在?是否启动过?以及让它自行关闭
- iPhone X适配以及iOS 11可能出现的常见崩溃(info.plist配置)
- 配置Info.plist (设置状态栏样式、自定义定位时系统弹出的提示语、配置3DTouch应用快捷菜单)
- iOS判断应用是否获取到系统相机 相册的授权 以及如何请求授权
- iPad Android系统下,平板设备判断横竖屏,以及横竖屏变化之后的事件触发(html + javascript)
- 【Android】判断某个AP是否在系统中存在(PackageManager与PackageInfo)