1. Get all the app pack names in your phone
- (void) touss{Class LSAWSC= Objc_getclass ("Lsapplicationworkspace"); NSObject* Workspace = [Lsawsc performselector:nsselectorfromstring (@"Defaultworkspace")]; Nsarray*arr = [Workspace performselector:nsselectorfromstring (@"allinstalledapplications")]; for(NSString * tmpinchARR) {NSString* Bundleid =[self getparsebundleidstring:tmp]; NSLog (@"%@", Bundleid); }}-(NSString *) getparsebundleidstring: (NSString *) description{NSString* ret =@""; NSString* target =[description description]; //iOS8.0 "LSApplicationProxy:com.apple.videos",//iOS8.1 "<LSApplicationProxy:0x898787998> Com.apple.videos",//iOS9.0 "<LSApplicationProxy:0x145efbb0> com.apple.PhotosViewService <file:///applications/photosviewservice.app> " if(target = =Nil) { returnret; } Nsarray* Arrobj = [target componentsseparatedbystring:@" "]; Switch([arrobj Count]) { Case 2://[iOS7.0 ~ iOS8.1] Case 3://[iOS8.1 ~ iOS9.0]{ret=[Arrobj Lastobject]; } Break; Case 4://[iOS9 +){ret= [Arrobj Objectatindex:2]; } Break; default: Break; } returnret;}
2. Open the app with the package name
Class LSAWSC = Objc_getclass ("Lsapplicationworkspace"); NSObject* Workspace = [Lsawsc performselector:nsselectorfromstring (@"Defaultworkspace")]; //iOS6 no Defaultworkspace . if([Workspace respondstoselector:nsselectorfromstring (@"Openapplicationwithbundleid:")] {[Workspace performselector:nsselectorfromstring (@"Openapplicationwithbundleid:") Withobject:@"com. CALENDAR.JBP"]; }
iphone gets all the apps in the phone (private library) + Open app with package name