Question

I know that other applications can call from your application via the URL schema. But not all applications are registered schema URL. So how can I launch that application?. I'm developing for iphone jaibroken.

Was it helpful?

Solution

I used this way:

void* sbServices = dlopen("/System/Library/PrivateFrameworks/SpringBoardServices.framework/SpringBoardServices", RTLD_LAZY);
int (*SBSLaunchApplicationWithIdentifier)(CFStringRef identifier, Boolean suspended) = dlsym(sbServices, "SBSLaunchApplicationWithIdentifier");
int result = SBSLaunchApplicationWithIdentifier((CFStringRef)bundleId, false);
dlclose(sbServices);

And you need entitlements granted to your app:

 <key>com.apple.springboard.launchapplications</key>
 <true/>

It can run on iOS 6.

OTHER TIPS

There are several ways you can launch an app using the Bundle ID.

SBApplication

SBApplication *app = [[objc_getClass("SBApplicationController") sharedInstance] applicationWithDisplayIdentifier:@"com.wrightscs.someapp"];
[[objc_getClass("SBUIController") sharedInstance] activateApplicationFromSwitcher: app];

SBApplicationController

SBUIController *uicontroller = (SBUIController *)[%c(SBUIController) sharedInstance];
SBApplicationController *appcontroller = (SBApplicationController *)[%c(SBApplicationController) sharedInstance];

if ([[UIDevice currentDevice] respondsToSelector:@selector(isMultitaskingSupported)])
{
    [uicontroller activateApplicationFromSwitcher:[[appcontroller applicationsWithBundleIdentifier:bundleID] objectAtIndex:0]];
}
else
{
    // doesn't work outside of Springboard
    [uicontroller activateApplicationAnimated:[[appcontroller applicationsWithBundleIdentifier:bundleID] objectAtIndex:0]];
}

There was another method I used in 4.x and SBUIController but that stopped working in 5.0 so I'm not going to post it.

As I know, only private api can do this. First

@interface PrivateApi_LSApplicationWorkspace
- (bool)openApplicationWithBundleID:(id)arg1;
@end

then use it

PrivateApi_LSApplicationWorkspace* _workspace;
_workspace = [NSClassFromString(@"LSApplicationWorkspace") new];
[_workspace openApplicationWithBundleID:bundleIdentifier];

You can check https://github.com/wujianguo/iOSAppsInfo.

I have tested just now: working in iOS 9.3.5 & 11.2 and also this method do not require any includes or dynamics loading of libs. Relies fully on obj-c runtime. And also this method do not require jailbroken device, can be done with xcode device and free developer account with provisioning profiles. Don't think that it would pass App store review process, but can be succesfully used in enterprise or ad-hoc destribution and so on.

id wrkS;
wrkS = [NSClassFromString(@"LSApplicationWorkspace")  performSelector:@selector(defaultWorkspace)];
[wrkS performSelector:@selector(openApplicationWithBundleID:) withObject:@"com.apple.reminders"];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top