Is it possible to get information about all apps installed on iPhone? -


is possible information (app icon, app name, app location) apps have been installed on iphone/ipod?

there way check if application installed or not, however, violate sandbox rules , apple *may reject app using this. has been done before other apps available in app store, feel free try it

sometimes may want check if specific app installed on device, in case use custom url schemes require other app installed (you gray out/disable buttons then). unfortunately, apple apparently not have function checks you, whipped 1 up. not enumerate every single app, instead uses mobileinstallation cache up-to-date springboard , holds info dictionaries of apps installed. although you're not "supposed" access cache, it's readable app store apps. here code @ least works fine simulator 2.2.1: code:

// declaration bool apcheckifappinstalled(nsstring *bundleidentifier); // bundle identifier (eg. com.apple.mobilesafari) used track apps  // implementation  bool apcheckifappinstalled(nsstring *bundleidentifier) {     static nsstring *const cachefilename = @"com.apple.mobile.installation.plist";     nsstring *relativecachepath = [[@"library" stringbyappendingpathcomponent: @"caches"] stringbyappendingpathcomponent: cachefilename];     nsdictionary *cachedict = nil;     nsstring *path = nil;     // loop through possible paths cache in     (short = 0; 1; i++)     {          switch (i) {     case 0: // jailbroken apps find cache here; home directory /var/mobile         path = [nshomedirectory() stringbyappendingpathcomponent: relativecachepath];         break;     case 1: // app store apps , simulator find cache here; home (/var/mobile/) 2 directories above sandbox folder         path = [[nshomedirectory() stringbyappendingpathcomponent: @"../.."] stringbyappendingpathcomponent: relativecachepath];         break;     case 2: // if app anywhere else, default hardcoded /var/mobile/         path = [@"/var/mobile" stringbyappendingpathcomponent: relativecachepath];         break;     default: // cache not found (loop not broken)         return no;         break; }          bool isdir = no;         if ([[nsfilemanager defaultmanager] fileexistsatpath: path isdirectory: &isdir] && !isdir) // ensure file exists             cachedict = [nsdictionary dictionarywithcontentsoffile: path];          if (cachedict) // if cache loaded, break loop. if loop not "broken," return no later (default: case)             break;     }      nsdictionary *system = [cachedict objectforkey: @"system"]; // first check system (jailbroken) apps     if ([system objectforkey: bundleidentifier]) return yes;     nsdictionary *user = [cachedict objectforkey: @"user"]; // user (app store /var/mobile/applications) apps     if ([user objectforkey: bundleidentifier]) return yes;      // if nothing returned yes already, we'll return no     return no; } 

here example of this, assuming app named "yourselfmadeapp" , app in app store. code:

nsarray *bundles2check = [nsarray arraywithobjects: @"com.apple.mobilesafari", @"com.yourcompany.yourselfmadeapp", @"com.blahblah.nonexistent", nil]; (nsstring *identifier in bundles2check)     if (apcheckifappinstalled(identifier))         nslog(@"app installed: %@", identifier);     else         nslog(@"app not installed: %@", identifier); 

log output: code:

2009-01-30 12:19:20.250 someapp[266:20b] app installed: com.apple.mobilesafari 2009-01-30 12:19:20.254 someapp[266:20b] app installed: com.yourcompany.yourselfmadeapp 2009-01-30 12:19:20.260 someapp[266:20b] app not installed: com.blahblah.nonexistent

try out before using it, think apple changed mobileinstallation.plist located , if change it, try out on actual device not simulator. luck!

http://www.iphonedevsdk.com/forum/iphone-sdk-development/37103-finding-out-what-apps-installed.html

pk


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -