Unfortunately no, unless you can figure out how to launch an app by bundle id in a non-jailbroken environment.
Otherwise, if you are in a jailbroken environment, you can use the following to launch an app by its bundle id:
Usage:
[self launch:(@"com.apple.mobilesafari")];
Code:
#pragma mark - Launch Application
-(void)launch:(NSString *)bundle {
Class SBApplicationController = objc_getClass("SBApplicationController");
id appController = [SBApplicationController sharedInstance];
NSArray *apps = [appController applicationsWithBundleIdentifier: bundle];
if ([apps count] > 0) {
//Wait .5 seconds.. then launch.
[self performSelector:@selector(launchTheApp:) withObject:[apps objectAtIndex:0] afterDelay: 0.5];
} else {
id app = [appController applicationWithDisplayIdentifier: bundle];
if (app) {
//Wait .5 seconds.. then launch.
[self performSelector:@selector(launchTheApp:) withObject:app afterDelay: 0.5];
}
}
}
-(void)launchTheApp:(id)app {
Class SBUIController = objc_getClass("SBUIController");
id uiController = [SBUIController sharedInstance];
if([uiController respondsToSelector:@selector(animateLaunchApplication:)]) {
[uiController animateLaunchApplication:app animateDefaultImage:YES];
} else {
[uiController activateApplicationAnimated:app];
}
}
Note:
Launching the app this way is basically the same as tapping on the Safari icon in SpringBoard. This will only launch into the app, resuming any web session that was previously active.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…