Open iOS App from Browser

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:

  1. Open your app's Info.plist and add a row with a key called URL Types.
  2. Expand the URL Types item, and Item 0 under it and you'll see URL Identifier
  3. Enter your app's bundle identifier (e.g. com.myCompany.myApp) as the URL Identifier value.
  4. Add another row to Item 0 and enter URL Schemes.
  5. 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).

How to open ios app using url?

I handled it via my server side code:

if ((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) {
location.replace("com.myapp://");
setTimeout(function() {
if (!document.webkitHidden) {
location.replace("https://itunes.apple.com/app/xxxxxxxx");
}
}, 25);}
else if ((navigator.userAgent.match(/android/i)) || (navigator.userAgent.match(/Android/i))) {
location.replace("https://play.google.com/store/apps/details?id=packagename&hl=en");}
else {
location.replace("http://www.example.com");}

I put this in my www.mysite.com/download page & share this url via campaigns.

How to open iOS app from browser?

Here is an example using jQuery:

$(document).ready(function() {

var user_agent_header = navigator.userAgent;

if(user_agent_header.indexOf('iPhone')!=-1 || user_agent_header.indexOf('iPod')!=-1 || user_agent_header.indexOf('iPad')!=-1){
setTimeout(function() { window.location="myApp://www.myapp.com";}, 25);
}

});

Opening hyperlink in a browser from iOS app

If you simply want to open a url using Safari, the following should help.

if let url = URL(string: "https://www.google.com") {
UIApplication.shared.open(url, options: [:])
}

In case you want to open hyperlinks on your WebView using Safari. Check this out. You need to use webView:shouldStartLoadWith delegate method. Remember to set lupView.delegate = self in your view controller or Storyboard.

    func webView(_ webView: UIWebView, shouldStartLoadWith request: URLRequest, navigationType: UIWebViewNavigationType) -> Bool {

if navigationType == .linkClicked {
// Open links in Safari
guard let url = request.url else { return true }

if #available(iOS 10.0, *) {
UIApplication.shared.open(url, options: [:], completionHandler: nil)
} else {
// openURL(_:) is deprecated in iOS 10+.
UIApplication.shared.openURL(url)
}
return false
}

// Handle other navigation types...
return true
}

iOS app, link to open website in browser, link in website closes browser

Launching Your Own Application via a Custom URL Scheme and Pass Parameters.

Here is a nice tutorial on Using Custom URL Scheme in iOS

As in the tutorial, you should parse the URL parameters and store them to use in the app in this method:

    - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
NSLog(@"Calling Application Bundle ID: %@", sourceApplication);
NSLog(@"URL scheme:%@", [url scheme]);
NSLog(@"URL query: %@", [url query]);

return YES;
}


Related Topics



Leave a reply



Submit