问题
Just now , I create a project based on Single View Application on Xcode6.3.1, then I create a button on Main.storyboard. The code is like this when the button touched:
NSString * bundleId = @"com.apple.iBooks";
void* sbServices = dlopen("/System/Library/PrivateFrameworks/SpringBoardServices.framework/SpringBoardServices", RTLD_LAZY);
int (*SBSLaunchApplicationWithIdentifier)(CFStringRef identifier, Boolean suspended) = dlsym(sbServices, "SBSLaunchApplicationWithIdentifier");
const char *strBundleId = [bundleId cStringUsingEncoding:NSUTF8StringEncoding];
int result = SBSLaunchApplicationWithIdentifier((__bridge CFStringRef)bundleId, NO);
dlclose(sbServices);
But it did not work. Then I do like this site tell me , Launch other application without URL schema in iphone? It did not work,either. Please help me. My device is iPhone4s, iOS 7.1.2, jailbroken.
回答1:
* For jail break you can proceed with this *
There is a mechanism known as URL scheme
, which can be used to open app from inside your app. but for that you need to do the proper url schemens setUp in your plist file. I strongly feel that you are not looking at this option.
* There is another way strictly not recommended ( except JAILBREAK PHONES) the API is private *, but you can do a try & enjoy in development mode.
openApplicationWithBundleID
: To open the app using bundle identifier.- (NSArray*)allInstalledApplications;
: This will list you all the installed application on your device.
If you want to see an interesting demo it this, kindly run this app in your phone & see the Apple Watch style, spring board, with all apps listed & can be launched on tap.
Hope that gives the better idea of the private api usage.
回答2:
Install the com.conradkramer.open
open package from Cydia and you can run open com.bundle.id
from shell via SSH or from an app.
来源:https://stackoverflow.com/questions/30476982/how-to-open-an-app-by-bundle-id-on-ios