[英]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.