uiapplication - Can an iOS App Switch to Safari Without Opening a Page? -
i know app can open particular url in safari doing this:
[[uiapplication sharedapplication] openurl:[nsurl urlwithstring:@"http://www.example.com/"]];
but, there way have app switch on safari without opening url?
i'd switch safari, let keep showing whatever page had open last time user looked @ it.
unfortunately no, unless can figure out how launch app bundle id in non-jailbroken environment.
otherwise, if in jailbroken environment, can use following launch app 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.. launch. [self performselector:@selector(launchtheapp:) withobject:[apps objectatindex:0] afterdelay: 0.5]; } else { id app = [appcontroller applicationwithdisplayidentifier: bundle]; if (app) { //wait .5 seconds.. 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 app way same tapping on safari icon in springboard. launch app, resuming web session active.
Comments
Post a Comment