Listing all installed apps on iPhone Programmatically?

大憨熊 提交于 2019-11-26 22:26:20

问题


I need to list all installed apps on iPhone with the help of coding. I am using a jailbroken iPhone. I have used ihasapp API, but it is not showing me the complete list of all installed apps. Please help me with the code.


回答1:


I use the AppList library myself to get a list of all installed apps. It uses private frameworks so it's also jailbreak-only. Check it out at https://github.com/rpetrich/AppList.

Update: @Nate is correct about this already being asked and answered. Check out: Get list of all installed apps




回答2:


I got a list of all installed application in my iPhone. It uses private framework but it's not jail broken device. Lookout below piece of code.

#include <objc/runtime.h>

    Class LSApplicationWorkspace_class = objc_getClass("LSApplicationWorkspace");
    SEL selector=NSSelectorFromString(@"defaultWorkspace");
    NSObject* workspace = [LSApplicationWorkspace_class performSelector:selector];

    SEL selectorALL = NSSelectorFromString(@"allApplications");
    NSLog(@"apps: %@", [workspace performSelector:selectorALL]);

I have tried this code and it's workings well on iOS9.




回答3:


There is a private API SBSCopyApplicationDisplayIdentifiers

It's signature is following

CFArrayRef SBSCopyApplicationDisplayIdentifiers(bool onlyActive, bool debuggable);

If you link to SpringboardServices framework and use it, it will return the list of installed apps.

Update 1

Here is example of usage copied from here

CFArrayRef SBSCopyApplicationDisplayIdentifiers(bool onlyActive, bool debuggable);

int main() {
    char buf[1024];
    CFArrayRef ary = SBSCopyApplicationDisplayIdentifiers(false, false);
    for(CFIndex i = 0; i < CFArrayGetCount(ary); i++) {
        CFStringGetCString(CFArrayGetValueAtIndex(ary, i),buf, sizeof(buf), kCFStringEncodingUTF8);
        printf("%s\n", buf);
    }
    return 0;
}

Don't forget to link to pravite framework SpringboardServices.




回答4:


I searched a lot to get the installed app list on iOS 11. But there is code to check the application currently installed on this device.

//If the device is iOS11
if ([[UIDevice currentDevice].systemVersion floatValue] >= 11.0) {
    NSBundle *container = [NSBundle bundleWithPath:@"/System/Library/PrivateFrameworks/MobileContainerManager.framework"];
    if ([container load]) {
        Class appContainer = NSClassFromString(@"MCMAppContainer");

        id test = [appContainer performSelector:@selector(containerWithIdentifier:error:) withObject:bundleId withObject:nil];
        NSLog(@"%@",test);
        if (test) {
            return YES;
        } else {
            return NO;
        }
    }
    return NO;

}



回答5:


Try this.

NSArray *appList = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:@"/Applications" error:nil];
NSLog(@"%@",appList);


来源:https://stackoverflow.com/questions/15332369/listing-all-installed-apps-on-iphone-programmatically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!