Open iOS app from browser
You can achieve what you're asking for by using a URL scheme. This will enable you to call the openUrl:
method with your application's url scheme which will then launch your app.
Here's how you setup a custom url scheme:
- Open your app's Info.plist and add a row with a key called URL Types.
- Expand the URL Types item, and Item 0 under it and you'll see URL Identifier
- Enter your app's bundle identifier (e.g. com.myCompany.myApp) as the URL Identifier value.
- Add another row to Item 0 and enter URL Schemes.
- Expand the URL Schemes and under Item 0 type in the name for your custom scheme (e.g. myScheme).
You should now be able to open your app from Safari by typing myScheme:// in the address bar.
Alternatively, from your app, you can launch the other app like this:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"myScheme://"]];
Note that you can also send parameters to the app you're launching with the url scheme (more on that here).
Launching Safari App without using any specific url from an iOS App
Actually we can open a specific app from safari. You have to create a custom url scheme for the application and open that link from safari like any other link is opened from safari.
Create a custom url scheme like
myApp://
Then open it from safari e.g on onClick of button.
Automate launching Safari from a iOS mobile app using appium
it doesn't allow you to sent commands to more than one app per session
Thats true, but you can run 2 sessions in a single test:
- create instance of appium driver with app-based capabilities
- do what you need in the app
- quit driver
- create instance of appium driver with browser-based capabilities
- do what you need in the safari
- quit driver
In a quick way it may look like:
@Test
public void testBothAppAndSafari() throws MalformedURLException {
URL appiumServerUrl = new URL("");
DesiredCapabilities appCaps = new DesiredCapabilities();
// put required native app capabilities in appCaps
DesiredCapabilities safariCaps = new DesiredCapabilities();
// put required safari capabilities in safariCaps
IOSDriver driver = new IOSDriver(appiumServerUrl, appCaps);
driver.findElement().click();
// do whatever you want with mobile app
driver.quit();
driver = new IOSDriver(appiumServerUrl, safariCaps);
driver.findElement().click();
// do whatever you want in safari
driver.quit();
}
Open Safari iOS App from Watch App
This is only possible if the iOS app happens to be running in the foreground. If you use the WatchConnectivity sendMessage API to wake the iOS app up in the background then you won't be able to open URLs and therefore not launch Safari.
How to open Safari from a WebApp in iOS 7
Having an anchor tag with target _blank
will work in iOS 7.0.3 but using window.open will not work and will remain to open within the webview in 7.0.3:
window.open('http://www.google.com/', '_blank');
Related Topics
Uinavigationbar Hide Back Button Text
How to Determine If an Annotation Is Inside of Mkpolygonview (Ios)
Closure Cannot Implicitly Capture a Mutating Self Parameter
Sharing Data in Between Apps in Ios
How to Detect Collision in Swift, Sprite Kit
How Does View Controller Containment Work in iOS 5
Are There APIs For Custom Vibrations in Ios
Ios9 Getting Error "An Ssl Error Has Occurred and a Secure Connection to the Server Cannot Be Made"
Nsurlsession With Nsblockoperation and Queues
Navigation Bar With Uiimage For Title
How to Animate the Background Color of a Uilabel
Detect iOS App Entering Background
How to Build For Armv6 and Armv7 Architectures With iOS 5
Displaying a Stock iOS Notification Banner When Your App Is Open and in the Foreground
Trying to Handle "Back" Navigation Button Action in Ios
Getting All Cookies from Wkwebview