利用私人的API獲得手機上所安裝的所有應用資訊(包括版本,名稱,bundleID,類型),apibundleid

來源:互聯網
上載者:User

利用私人的API獲得手機上所安裝的所有應用資訊(包括版本,名稱,bundleID,類型),apibundleid

MobileCoreService這個系統的庫,裡面有個私人的類LSApplicationWorkspace

,利用運行時可以獲得私人類裡面的方法,- (id)allInstalledApplications;  該方法能夠獲得裝置上所有的應用資訊,包括系統的和使用者的應用

獲得的應用的資訊是一個類對象LSApplicationProxy,該對象裡面有方法獲得app的版本,名稱,bundleID,類型

 

好了直接上代碼首先引入標頭檔#include <objc/runtime.h>

- (void)getAllApps{    //擷取手機上所有的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");    for (int i = 0; i < apps.count; i++) {        NSObject *temp = apps[i];        if ([temp isKindOfClass:LSApplicationProxy_class]) {            //應用的bundleId            NSString *appBundleId = [temp performSelector:NSSelectorFromString(@"applicationIdentifier")];               //應用的名稱            NSString *appName = [temp performSelector:NSSelectorFromString(@"localizedName")];            //應用的類型是系統的應用還是第三方的應用        NSString * type = [temp performSelector:NSSelectorFromString(@"applicationType")];            //應用的版本            NSString * shortVersionString = [temp performSelector:NSSelectorFromString(@"shortVersionString")];                        NSLog(@"類型=%@應用的BundleId=%@ ++++應用的名稱=%@版本號碼=%@",type,appBundleId,appName,shortVersionString);                           }    }    }

 

這裡附上MobileCoreServices裡面的標頭檔https://github.com/nst/iOS-Runtime-Headers/tree/master/Frameworks/MobileCoreServices.framework

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.