iphone gets all the apps in the phone (private library) + Open app with package name

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.