简体   繁体   English

在不使用iOS应用程序中的任何特定URL的情况下启动Safari App

[英]Launching Safari App without using any specific url from an iOS App

In one of my iOS App, I have to just launch the Safari App and not open some specific Url in Safari which can be achieved by this: 在我的一个iOS应用程序中,我必须启动Safari应用程序,而不是在Safari中打开一些特定的URL,这可以通过以下方式实现:

NSURL *url = [NSURL URLWithString:@"http://www.stackoverflow.com"];

if (![[UIApplication sharedApplication] openURL:url]) {
NSLog(@"%@%@",@"Failed to open url:",[url description]);
}

But I only need to launch safari App with last tab open (in the same state that I leave before entering that iOS App). 但是我只需要打开最后一个标签打开的safari应用程序(与我在进入iOS应用程序之前离开的状态相同)。

Any suggestion and help will be welcome. 欢迎任何建议和帮助。 Thanks! 谢谢!

Actually we can open a specific app from safari. 实际上我们可以从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. 您必须为应用程序创建自定义URL方案,并从safari打开该链接,就像从safari打开任何其他链接一样。

Create a custom url scheme like 创建一个自定义网址方案,如

myApp:// 对myApp://

Then open it from safari eg on onClick of button. 然后从safari打开它,例如onClick按钮。

Objective C 目标C.

NSURL *url = [NSURL URLWithString:@"http://about:blank"];
if (![[UIApplication sharedApplication] openURL:url]) {
    NSLog(@"%@%@",@"Failed to open url:",[url description]);
}  

Swift 3.0 Swift 3.0

UIApplication.shared().openURL(URL(string: "http://about:blank")!)

Hope It will help you. 希望它会对你有所帮助。

Add Comment if you require any other information. 如果您需要任何其他信息,请添加评论。

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

相关问题 iOS 9.3.2自定义URL方案未从Safari启动应用 - iOS 9.3.2 Custom URL Scheme not launching app from Safari 使用 appium 从 iOS 移动应用程序自动启动 Safari - Automate launching Safari from a iOS mobile app using appium 使用存储在数组中的URL从应用程序启动Safari - launching Safari from an app using URL stored in the array 如何使用自定义iOS应用程序中的URL链接将Safari(或Adobe或任何其他应用程序)打开到特定网页或文档? - How to open Safari (or Adobe, or any other app) to a specific webpage or document using a URL link from within my custom iOS application? 如何启用从Safari iOS中的深层链接启动应用程序 - How to enable launching of the app from deep link in Safari iOS 从ios框架启动应用程序或在野生动物园中打开链接 - launching app or opening link in safari from ios framework 从Safari启动应用程序或应用程序商店? - Launching app OR app store from Safari? 当 Safari 不是使用 URL 方案的默认浏览器时,从 iOS 14 上的应用程序启动 Safari - Launch Safari from app on iOS 14 when Safari is not the default browser using the scheme of the URL 测试任何应用程序是否可以在iOS上的移动Safari中处理url方案 - Test if any app can handle a url scheme in mobile safari on iOS (iOS)使用URLSchemes从同一应用启动应用 - (iOS)Launching app from the same app using URLSchemes
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM