获取手机已安装app的bundleid(上)

获取ios10之前的手机已安装app的bundleid

- (void)touss

{

    Class lsawsc = objc_getClass("LSApplicationWorkspace");

    NSObject* workspace = [lsawsc performSelector:NSSelectorFromString(@"defaultWorkspace")];

    NSArray *Arr = [workspace performSelector:NSSelectorFromString(@"allInstalledApplications")];

    for(NSString* tmpinArr)

    {

        NSString* bundleid = [selfgetParseBundleIdString:tmp];

        NSLog(@"%@",bundleid);

    }

}

- (NSString*)getParseBundleIdString:(NSString*)description

{

    NSString* ret =@"";

    NSString* target = [descriptiondescription];


    // iOS8.0 "LSApplicationProxy: com.apple.videos",

    // iOS8.1 " com.apple.videos",

    // iOS9.0 " com.apple.PhotosViewService "


    if(target ==nil)

    {

        returnret;

    }

    NSArray * arrObj = [target componentsSeparatedByString:@" "];

    switch([arrObjcount])

    {

        case 2: // [iOS7.0 ~ iOS8.1)

        case 3: // [iOS8.1 ~ iOS9.0)

        {

            ret = [arrObjlastObject];

        }

            break;


        case4:// [iOS9 +)

        {

            ret = [arrObjobjectAtIndex:2];

        }

            break;


        default:

            break;

    }

    returnret;

}

你可能感兴趣的:(获取手机已安装app的bundleid(上))