How to get links to open in the native browser in iOS Meteor apps?

坚强是说给别人听的谎言 提交于 2019-12-24 03:25:12

问题


How do I prevent external links from opening in the in-app browser in apps built with Meteor for iOS? I want them to open in Safari instead.


回答1:


You'll need to download and install an apache cordova plugin to add this functionality into your meteor ios app.

Simply run this command into your terminal

meteor add cordova:cordova-plugin-inappbrowser@https://github.com/apache/cordova-plugin-inappbrowser/tarball/ba7cbe58d5812b51c3ece1

(here is a ref to the tarball/ba7cbe58d5812b51c3ece1) (use the latest commit to master branch)

Then simply add this into your meteor template to launch the system default browser app with the external link:

<a href="" onclick="window.open('http://www.example-url.com', '_system');">
Hope this helps!
</a>

Run: meteor run ios-device

(select your trusty simulator and test her out)




回答2:


Nick's answer to use the inappbrowser Cordova plugin is sound, but with the error you're seeing, make sure you're providing a full commit hash URL for the meteor tool/build to resolve. At the time of this writing, the correct Terminal command to use the latest commit is:

meteor add cordova:cordova-plugin-inappbrowser@https://github.com/apache/cordova-plugin-inappbrowser/tarball/bc9036d90a1f3f2220b5fc29b77cf2405e7fd781

The remaining steps are the same; use the _system target in your project's code for the link:

<a href="" onclick="window.open('http://external.url', '_system')">Open</a>

Then kick off a meteor build for your desired mobile platform and Cordova should apply the plugin without issue. Verified these steps work on Meteor 1.2.1.



来源:https://stackoverflow.com/questions/29497556/how-to-get-links-to-open-in-the-native-browser-in-ios-meteor-apps

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!