美文网首页
获取手机上所有的app唯一标示及版本号

获取手机上所有的app唯一标示及版本号

作者: 悲酥清风__ | 来源:发表于2017-06-27 18:02 被阅读112次

#import <objc/runtime.h>

- (NSArray *)getAllAppsFromDevice

{

//获取手机上所有的app

Class LSApplicationWorkspace_class = objc_getClass("LSApplicationWorkspace");

NSObject *workspace = [LSApplicationWorkspace_class performSelector:@selector(defaultWorkspace)];

NSArray *apps = [workspace performSelector:@selector(allInstalledApplications)];

Class LSApplicationProxy_class = objc_getClass("LSApplicationProxy");

NSMutableArray *deviceApps = [NSMutableArray new];

for (int i = 0; i < apps.count; i++) {

NSObject *temp = apps[i];

if ([temp isKindOfClass:LSApplicationProxy_class]) {

//            ApplicationModel *appModel = [[ApplicationModel alloc] init];

NSString *tempKey = [temp performSelector:NSSelectorFromString(@"applicationIdentifier")];

//            if ([tempKey containsOtherString:@"apple"]) {

//                continue; itemName

//            }

//版本

NSString *tempVersionNumber = [temp performSelector:NSSelectorFromString(@"shortVersionString")];

//            appModel.appNumber = tempVersionNumber;

NSString *tempName = [temp performSelector:NSSelectorFromString(@"bundleIdentifier")];

NSLog(@"应用名-%d:%@",i,tempName);

//bundle id

NSString *tempAppkey = [temp performSelector:NSSelectorFromString(@"applicationIdentifier")];

//            appModel.appKey = tempAppkey;

//            [deviceApps addObject:appModel];

}

}

return [deviceApps copy];

}

相关文章

网友评论

      本文标题:获取手机上所有的app唯一标示及版本号

      本文链接:https://www.haomeiwen.com/subject/jibsvttx.html