No results found

Launching external apps in App Cloud

Sometimes it's necessary to launch an external app from within your own app. (After all, your app can't do everything!) In App Cloud, it's easy to do with the device method bc.device.openURI().

For example, say you want to open an external web browser whenever a user taps a button:

$("#exampleButton").on("tap", function (evt) {
    // note both callback functions are optional
    bc.device.openURI("", onSuccess, onError);

Easy enough! But what if you have many buttons, each leading to a different URI? Consider embedding each URI in a data attribute:

<button data-href="">Open me</button>
<button data-href="">Me too!</button>

Then you can listen for a tap event on any element having a "data-href" attribute and extract the URI from that element:

$("[data-href]").on("tap", function (evt) {
    var uri = this.getAttribute("data-href");
    bc.device.openURI(uri, onSuccess, onError);

Special cases

In some cases, iOS uses specific apps to handle special types of URLs. For example, any URL beginning with "" opens in the Maps app:

Android may present the user with several options in order to determine the "intent" of the action:

Using modal windows

If you're simply opening a web page, you might want to open it modally instead of bouncing the user out of your app. Just set "modalWebBrowser" to true in the device call:

bc.device.openURI(url, onSuccess, onError, { modalWebBrowser: true });

You can also use links to accomplish the same thing without JavaScript:

<a href="">For example ...</a>

p.s. Get more tips and tricks (and share your own) by joining the Brightcove App Cloud discussion group on Google.