简体   繁体   English

iOS应用程序,链接以在浏览器中打开网站,网站中的链接关闭浏览器

[英]iOS app, link to open website in browser, link in website closes browser

Objective : A button in iOS native app when clicked opens a url (webpage) in native browser (safari or other, not UiWebView as it no longer supports html file control api) then, using javascript in the opened webpage, close that browser window so revealing the app again. 目标:单击iOS本机应用程序中的按钮后,将在本机浏览器(Safari或其他浏览器,而不是UiWebView,因为它不再支持html文件控制api)中打开一个url(网页),然后在打开的网页中使用javascript关闭该浏览器窗口,再次显示该应用程序。

Opening the URL from the native app is not an issue: How to launch safari and open URL from iOS app? 从本机应用程序打开URL不是问题: 如何启动Safari和从iOS应用程序打开URL?

Closing that resultant browser window is an issue, is there a way to accomplish this? 关闭结果浏览器窗口是一个问题,有没有办法做到这一点?


Launching Your Own Application via a Custom URL Scheme and Pass Parameters. 通过自定义URL方案和传递参数启动您自己的应用程序。

Here is a nice tutorial on Using Custom URL Scheme in iOS 这是有关在iOS中使用自定义URL方案的不错的教程

As in the tutorial, you should parse the URL parameters and store them to use in the app in this method: 如本教程中所述,您应该解析URL参数,并通过以下方法将其存储以在应用程序中使用:

    - (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;
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM