NativeScript - Launch another app from Nativescript app

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-09 20:16:38

问题


In NativeScript, is it possible to launch another app from within a Nativescript app?

Let's say I have a button in an app and when pressed it launches the Waze Navigation app with coordinates to a location.

Is this possible with NativeScript?

Thanks.


回答1:


Waze uses the url scheme 'waze://' which you will need to first register in your Info.plist if your app will be running on devices w/ iOS 9 and later.

<key>LSApplicationQueriesSchemes</key>
    <array>
        <string>waze</string>
    </array>

You can then use the openUrl method from the included utils module

var utils = require('utils/utils');
utils.openUrl('waze://?ll=37.44469,-122.15971&z=10');

The NativeScript openUrl handles both the canOpenURL and subsequent openURL for you




回答2:


Should be easy, kinda works with schemes on both platforms...just convert this code to JS for iOS, find the equivalent for android.

How to launch another app from an iPhone app

The answer to "In Nativescript is it possible" is pretty much always yes since we're just marshalling calls into the OS' not needing native wrappers or anything around functionality.

Good luck!



来源:https://stackoverflow.com/questions/38964197/nativescript-launch-another-app-from-nativescript-app

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