我的网络应用程序存在一些问题,如果用户从 Facebook 应用程序单击链接,它将使用它自己的浏览器/ WebView ,但需要使用 Safari 或 Chrome 才能运行该页面。
在研究 ( this issue ) 时,我发现您可以在 Android 设备上使用 googlechrome://navigate?url=example.com 打开 chrome,并且 googlechrome://myurl.com 从 iOS 也可以打开 Chrome,但如果用户的设备是 iOS,我需要一种打开 Safari 的方法。
有办法吗?
Ps.: 用户在 Facebook 中点击的链接会转到一个登陆页面,在这个页面中有一个指向 webapp 的按钮。当用户单击此按钮时,我将打开 Chrome/Safari。
提前致谢!
最佳答案
SO 中有一些类似主题的答案。类似的东西
NSString *yourUrl = @"http://yourURL";
SFSafariViewController *svc= [[SFSafariViewController alloc] initWithURL:[NSURL URLWithString: yourUrl]];
[self presentViewController:svc animated:YES completion:nil];
在 Swift 中,这是
let yourUrl = "http://www.yourURL.com";
let svc = SFSafariViewController.init(url: URL);
svc.delegate = self
present(svc, animated: true);
应该可以。
如果您使用的是 Javascript,请查看 Force link to open in mobile safari from a web app with javascript
看来你需要做类似的事情
HTML:
<div id="foz" data-href="http://www.google.fi">Google</div>
JS:
document.getElementById("foz").addEventListener("click", function(evt) {
var a = document.createElement('a');
a.setAttribute("href", this.getAttribute("data-href"));
a.setAttribute("target", "_blank");
var dispatch = document.createEvent("HTMLEvents");
dispatch.initEvent("click", true, true);
a.dispatchEvent(dispatch);
}, false);
在 ( http://www.hakoniemi.net/labs/linkkitesti.html ) 测试
来源:
Open links in Safari instead of UIWebVIew?
How to force links to open in iOS Safari?
Force link to open in mobile safari from a web app with javascript
关于ios - 相当于 Safari 的 googlechrome ://myurl. com,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53435403/
这里有一个很好的答案解释了如何在Ruby中下载文件而不将其加载到内存中:https://stackoverflow.com/a/29743394/4852737require'open-uri'download=open('http://example.com/image.png')IO.copy_stream(download,'~/image.png')我如何验证下载文件的IO.copy_stream调用是否真的成功——这意味着下载的文件与我打算下载的文件完全相同,而不是下载一半的损坏文件?documentation说IO.copy_stream返回它复制的字节数,但是当我还没有下
我正在尝试解析一个文本文件,该文件每行包含可变数量的单词和数字,如下所示:foo4.500bar3.001.33foobar如何读取由空格而不是换行符分隔的文件?有什么方法可以设置File("file.txt").foreach方法以使用空格而不是换行符作为分隔符? 最佳答案 接受的答案将slurp文件,这可能是大文本文件的问题。更好的解决方案是IO.foreach.它是惯用的,将按字符流式传输文件:File.foreach(filename,""){|string|putsstring}包含“thisisanexample”结果的
这个问题在这里已经有了答案:关闭10年前。PossibleDuplicate:Pythonconditionalassignmentoperator对于这样一个简单的问题表示歉意,但是谷歌搜索||=并不是很有帮助;)Python中是否有与Ruby和Perl中的||=语句等效的语句?例如:foo="hey"foo||="what"#assignfooifit'sundefined#fooisstill"hey"bar||="yeah"#baris"yeah"另外,类似这样的东西的通用术语是什么?条件分配是我的第一个猜测,但Wikipediapage跟我想的不太一样。
什么是ruby的rack或python的Java的wsgi?还有一个路由库。 最佳答案 来自Python标准PEP333:Bycontrast,althoughJavahasjustasmanywebapplicationframeworksavailable,Java's"servlet"APImakesitpossibleforapplicationswrittenwithanyJavawebapplicationframeworktoruninanywebserverthatsupportstheservletAPI.ht
1.错误信息:Errorresponsefromdaemon:Gethttps://registry-1.docker.io/v2/:net/http:requestcanceledwhilewaitingforconnection(Client.Timeoutexceededwhileawaitingheaders)或者:Errorresponsefromdaemon:Gethttps://registry-1.docker.io/v2/:net/http:TLShandshaketimeout2.报错原因:docker使用的镜像网址默认为国外,下载容易超时,需要修改成国内镜像地址(首先阿里
Java的Collections.unmodifiableList和Collections.unmodifiableMap在Ruby标准API中是否有等价物? 最佳答案 使用freeze应用程序接口(interface):Preventsfurthermodificationstoobj.ARuntimeErrorwillberaisedifmodificationisattempted.Thereisnowaytounfreezeafrozenobject.SeealsoObject#frozen?.Thismethodretur
print"Enteryourpassword:"pass=STDIN.noecho(&:gets)puts"Yourpasswordis#{pass}!"输出:Enteryourpassword:input.rb:2:in`':undefinedmethod`noecho'for#>(NoMethodError) 最佳答案 一开始require'io/console'后来的Ruby1.9.3 关于ruby-为什么不能使用类IO的实例方法noecho?,我们在StackOverflow上
是否有Ruby等效于Python的方法来获取在字符串末尾结束的子字符串,如str[3:]?必须输入字符串的长度并不方便。 最佳答案 传递最后一个元素=-1的范围str[3..-1] 关于python-Ruby相当于Pythonstr[3:],我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/12978768/
我想知道,是否有一些流操作可以像ruby中的each_with_index那样做。其中each_with_index遍历值以及值的索引。 最佳答案 没有专门用于该目的的流操作。但您可以通过多种方式模仿该功能。索引变量:以下方法适用于顺序流。int[]index={0};stream.forEach(item->System.out.printf("%s%d\n",item,index[0]++));外部迭代:以下方法适用于并行流,只要原始集合支持随机访问。Listtokens=...;IntStream.range(0,toke
在JavaScript中你可以这样做:setInterval(func,delay);我似乎无法在谷歌上找到任何我真正要找的东西。是否有ruby等价物?提前致谢。 最佳答案 你可以做类似的事情:Thread.newdoloopdosleepdelay#yourcodehereendend或者你可以定义一个函数:#@return[Thread]returnloopthreadreferencedefset_interval(delay)Thread.newdoloopdosleepdelayyield#callpassedblocke