GithubHelp home page GithubHelp logo

eddyverbruggen / custom-url-scheme Goto Github PK

View Code? Open in Web Editor NEW
1.0K 54.0 365.0 114 KB

:link: Launch your Cordova/PhoneGap app by a Custom URL scheme like mycoolapp://

Java 40.89% JavaScript 48.90% C# 10.21%

custom-url-scheme's Introduction

Custom URL scheme Cordova/PhoneGap Plugin

launch your app by a link like this: mycoolapp://

NPM version Downloads Twitter Follow

  1. Description
  2. Installation
    1. Automatically (CLI / Plugman)
    2. Manually
    3. PhoneGap Build
  3. Usage
    1. iOS
    2. Meteor
  4. URL Scheme hints
  5. License

BEWARE:

- This Apache Cordova issue causes problems with Cordova-iOS 3.7.0: the handleOpenURL function is not invoked upon cold start. Use a higher or lower version than 3.7.0.

- As of iOS 9.2, the dialog Open in "mycoolapp"? no longer blocks JS, so if you have a short timeout that opens the app store, the user will be taken to the store before they have a chance to see and answer the dialog. See below for available solutions.

1. Description

This plugin allows you to start your app by calling it with a URL like mycoolapp://path?foo=bar

iOS specifics

  • Forget about using config.xml to define a URL scheme. This plugin adds 2 essential enhancements:
    • Uniform URL scheme with Android (for which there is no option to define a URL scheme via PhoneGap configuration at all).
    • You still need to wire up the Javascript to handle incoming events. This plugin assists you with that.
  • Tested on iOS 5.1, 6 and 7.

Android specifics

  • Unlike iOS, there is no way to use config.xml to define a scheme for your app. Now there is.
  • Tested on Android 4.3, will most likely work with 2.2 and up.
  • If you're trying to launch your app from an In-App Browser it opened previously, then use this In-App Browser plugin fork which allows that.
  • In case you have a multi-page app (multiple HTML files, and all implementing handleOpenURL), set the preference CustomURLSchemePluginClearsAndroidIntent to true in config.xml so the function won't be triggered multiple times. Note that this may interfere with other plugins requiring the intent data.

2. Installation

Automatically (CLI / Plugman)

LaunchMyApp is compatible with Cordova Plugman. Replace mycoolapp by a nice scheme you want to have your app listen to:

Latest release on npm:

$ cordova plugin add cordova-plugin-customurlscheme --variable URL_SCHEME=mycoolapp

Bleeding edge master version from Github:

$ cordova plugin add https://github.com/EddyVerbruggen/Custom-URL-scheme.git --variable URL_SCHEME=mycoolapp

(Note that the Phonegap CLI didn't support --variable before version 3.6.3, so please use the Cordova CLI as shown above in case you're on an older version)

The LaunchMyApp.js file is brought in automatically.

Note for iOS: there was a bug in CLI which caused an error in your *-Info.plist. Please manually remove the blank line and whitespace (if any) from NSMainNibFile and NSMainNibFile~ipad (or your app won't start at all).

Manually

Don't shoot yourself in the foot - use the CLI! That being said, here goes:

iOS

1. Copy www/ios/LaunchMyApp.js to www/js/plugins/LaunchMyApp.js and reference it in your index.html:

<script type="text/javascript" src="js/plugins/LaunchMyApp.js"></script>

2. Add this to your *-Info.plist (replace URL_SCHEME by a nice scheme you want to have your app listen to, like mycoolapp):

<key>CFBundleURLTypes</key>
<array>
  <dict>
    <key>CFBundleURLSchemes</key>
    <array>
      <string>URL_SCHEME</string>
    </array>
  </dict>
</array>

Android

1. Copy www/android/LaunchMyApp.js to www/js/plugins/LaunchMyApp.js and reference it in your index.html:

<script type="text/javascript" src="js/plugins/LaunchMyApp.js"></script>

2. Add the following xml to your config.xml to always use the latest version of this plugin:

<plugin name="LaunchMyApp" value="nl.xservices.plugins.LaunchMyApp"/>

3. Copy LaunchMyApp.java to platforms/android/src/nl/xservices/plugins (create the folders)

4. Add the following to your AndroidManifest.xml inside the /manifest/application/activity node (replace URL_SCHEME by a nice scheme you want to have your app listen to, like mycoolapp):

<intent-filter>
  <data android:scheme="URL_SCHEME"/>
  <action android:name="android.intent.action.VIEW" />
  <category android:name="android.intent.category.DEFAULT" />
  <category android:name="android.intent.category.BROWSABLE" />
</intent-filter>

5. In AndroidManifest.xml set the launchMode to singleTask to avoid issues like [#24]. <activity android:launchMode="singleTask" ..

PhoneGap Build

Using LaunchMyApp with PhoneGap Build requires you to add the following xml to your config.xml to use the latest version of this plugin (replace mycoolapp by a nice scheme you want to have your app listen to):

<gap:plugin name="cordova-plugin-customurlscheme" source="npm">
  <param name="URL_SCHEME" value="mycoolapp" />
</gap:plugin>

The LaunchMyApp.js file is brought in automatically.

NOTE: When Hydration is enabled at PGB, this plugin may not work.

Restoring cordova plugin settings on plugin add or update

In order to be able to restore the plugin settings on cordova plugin add, one need to add the following feature into config.xml. Note that if you added the plugin with the --save param you will find this in your config.xml already, except for the variable tag which is likely a param tag. Change that.

  <feature name="Custom URL scheme">
    <param name="id" value="cordova-plugin-customurlscheme" />
    <param name="url" value="https://github.com/EddyVerbruggen/Custom-URL-scheme.git" />
    <variable name="URL_SCHEME" value="mycoolapp" /><!-- change as appropriate -->
  </feature>

Please notice that URL_SCHEME is saved as variable, not as prop. However if you do cordova plugin add with a --save option, cordova will write the URL_SCHEME as a prop, you need to change the tag name from param to variable in this case.

These plugin restore instructions are tested on: cordova-cli 4.3.+ and cordova-android 3.7.1+

3. Usage

1a. Your app can be launched by linking to it like this from a website or an email for example (all of these will work):

<a href="mycoolapp://">Open my app</a>
<a href="mycoolapp://somepath">Open my app</a>
<a href="mycoolapp://somepath?foo=bar">Open my app</a>
<a href="mycoolapp://?foo=bar">Open my app</a>

mycoolapp is the value of URL_SCHEME you used while installing this plugin.

1b. If you're trying to open your app from another PhoneGap app, use the InAppBrowser plugin and launch the receiving app like this, to avoid a 'protocol not supported' error:

<button onclick="window.open('mycoolapp://', '_system')">Open the other app</button>

2. When your app is launched by a URL, you probably want to do something based on the path and parameters in the URL. For that, you could implement the (optional) handleOpenURL(url) method, which receives the URL that was used to launch your app.

function handleOpenURL(url) {
  console.log("received url: " + url);
}

If you want to alert the URL for testing the plugin, at least on iOS you need to wrap it in a timeout like this:

function handleOpenURL(url) {
  setTimeout(function() {
    alert("received url: " + url);
  }, 0);
}

A more useful implementation would mean parsing the URL, saving any params to sessionStorage and redirecting the app to the correct page inside your app. All this happens before the first page is loaded.

iOS Usage

A common method of deeplinking is to give the user the URL of a webpage (for instance http://linker.myapp.com/pathfoo) that opens the app if installed or the app store if not. This can be done in the following ways, depending on the desired UX:

  1. The page content has a button that says "Install app" and when clicked opens the app store by doing location.href = 'itms-apps://itunes.apple.com/us/app/mycoolapp/idfoo'. On page load, do location.href = 'mycoolapp://pathfoo'. If the user has the app, they will see a dialog that says Open in "mycoolapp"? [Cancel] [Open]. If the user does not have the app, they will see an alert that says Cannot Open Page: Safari cannot open the page because the address is invalid. Once they dismiss the alert, they see the button that opens the app store, and they tap it.
  2. The page has two buttons: one that opens the app, and one that opens the app store.
  3. On page load, open a Universal Link using cordova-universal-links-plugin. (A Universal Link either opens the app or the app store.) Then fall back to one of the above methods if Univeral Links is not supported.

You can also use a service that provides pages that do #3 for you, such as Branch.

CSP - or: handleOpenURL doesn't work

The Whitelist plugin will prevent inline JS from executing, unless you whitelist the url scheme. Please see this SO issue for details.

Meteor / getLastIntent (Android only)

When running a meteor app in the cordova environment, handleOpenURL doesn't get called after a cold start, because cordova resets the javascript world during startup and our timer waiting for handleOpenURL gets vanished (see #98). To get the intent by which the app was started in a meteor cordova app you need to ask for it from the meteor side with getLastIntent like this.

Meteor.startup(function() {
  if (Meteor.isCordova) {
    window.plugins.launchmyapp.getLastIntent(function(url) {
      if (intent.indexOf('mycoolapp://' > -1)) {
        console.log("received url: " + url);
      } else {
        return console.log("ignore intent: " + url);
      }
    }, function(error) {
      return console.log("no intent received");
    });
    return;
  }
});

4. URL Scheme hints

Please choose a URL_SCHEME which which complies to these restrictions:

  • Don't use an already registered scheme (like fb, twitter, comgooglemaps, etc).
  • Use only lowercase characters.
  • Don't use a dash - because on Android it will become underscore _.
  • Use only 1 word (no spaces).

TIP: test your scheme by installing the app on a device or simulator and typing yourscheme:// in the browser URL bar, or create a test HTML page with a link to your app to impress your buddies.

5. License

The MIT License (MIT)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

custom-url-scheme's People

Contributors

alex-slesarev avatar andruhon avatar cef62 avatar davidofwatkins avatar duaneobrien avatar eddyverbruggen avatar eionrobb avatar extempl avatar fbnitro avatar guiassemany avatar icykira avatar lorensr avatar nadyaa avatar oacdesigns avatar patte avatar pke avatar rs22 avatar tobiasmarklund avatar trumpet2012 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

custom-url-scheme's Issues

Simple example of handleOpenURL in action

Would you be able to provide a simple example of the handleOpenURL in action. I have the plugin working to load the app from a link, but I'm getting no indication that handleOpenURL is ever firing. I have it in the head of my index.html:
function handleOpenURL(url) {
setTimeout(function() {
alert("received url: " + url);
}, 0);
}

Return to Safari on IOS after closing app

Hi,

First of all: great plugin and thanks for making it available.

We created an app to connect to openTok video calling sessions. The app is launched from a webpage on our platform. When the user uses an iPad, terminates the call and presses Home, the app is not suspended but terminated. So far, so good.

Our problem is that the user (using an iPad) then manually has to revive the Safari browser (app) to continue working in the platform. As Safari was suspended, the user-session is still ok.
What we would really like to have in our usecase is that after pressing Home, the user is redirected to where he was in Safari automatically, that is, the previous active app on the iPad.

I couln't find any references to this on Google.
Does anyone have any ideas how to get this working?

handleOpenURL Problems After Moving to PhoneGap v3.5.0 and/or v3.6.3

Hi,
When using PhoneGap Build v3.3 with no settings for launchMode or reference to

xmlns:android in config.xml

I could start a web browser from within my app using "window.open". From an external website page within that web browser I could LaunchMyApp via a URL and read the passed URL in my app. However this would open up a new instance of my app each time. But I was okay with that.

My index.html auto-calls main.html where all my app code sits.
I have function onLoad() in the html head.
I am using body onload="onLoad()" to call is deviceReady
I have placed function handleOpenURL(url) {} inside the main.html head.
(Is this the correct place for it?)

With PG v3.3 all seems to work fine, I get passed the URL and can read the passed parameters.

HOWEVER

I am now building the same app with PhoneGap v3.5.0 and/or v3.6.3 (I have tried both)

LaunchMyApp works every time BUT I cannot read the passed URL any more!!

I have added in config.xml:

xmlns:android = "http://schemas.android.com/apk/res/android"

AND tried different combinations of "preference" and "activity" as suggested in other posts:

<preference name="AndroidLaunchMode" value="singleTop" />
<gap:config-file platform="android" parent="/manifest/application"> 
      <activity android:launchMode="singleTop" />
</gap:config-file>

I have tried "singleTop" and "singleTask" and "standard"

But whatever combination I try I cannot read the passed URL - it is as if the handleOpenURL is not being triggered.

May be I am not placing handleOpenURL in the correct part of my project - should it go in the html head?

Summary Snippets:

Config.xml

<?xml version="1.0" encoding="UTF-8"?>
<widget xmlns = "http://www.w3.org/ns/widgets"
                xmlns:gap = "http://phonegap.com/ns/1.0"
        xmlns:android = "http://schemas.android.com/apk/res/android" 
        id = "MY ID HERE"
                version = "2.0.1">
<name>MY NAME/name>
<description> DESCRIPTION HERE </description>
<author href=" AUTHOR DETAILS </author>
<preference name="phonegap-version" value="3.6.3" />           (also tried with 3.5.0)
<!-- 3.6.3 & 3.5.0 fail to pass URL, Also tried the following preference & activity in different combinations -->
<preference name="AndroidLaunchMode" value="singleTop" />
<gap:config-file platform="android" parent="/manifest/application"> 
      <activity android:launchMode="singleTop" />
</gap:config-file>

My Main Project Code:

Index.html (redirects to main.html)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Local Bonza App</title>
<script>
window.location='./main.html';
</script>
</head>
<body>
</body>
</html>

Main.html

<head>
<meta charset="utf-8">
<title>My Project</title>
<link href="jquery-mobile/jquery.mobile-1.4.2.min.css" rel="stylesheet" type="text/css"/>
<link href= all the other link files.......
<script>
function handleOpenURL(url) {
  setTimeout(function() {
    alert("passedURL: " + url);
             <All my parse code goes here>
  }, 4000);
}
function onLoad() {
document.addEventListener("deviceready", onDeviceReady, false);
}
</script>
</head>
<body onload="onLoad()">

Edit:

After some playing the problem is related to DeviceReady and using body onload="onLoad()"

Function handleOpenURL(url) always fails when using body onload="onLoad()" to call document.addEventListener("deviceready", onDeviceReady, false);

How do I use function handleOpenURL(url) with body onload="onLoad()" calling document.addEventListener("deviceready", onDeviceReady, false);

If I simply have:

document.addEventListener("deviceready", onDeviceReady, false);
function handleOpenURL(url) {
    setTimeout(function() {
    alert("passedURL: " + url);
             <All my parse code goes here>
  }, 600);
}

This captures the passed URL as wanted BUT then the rest of my app is broken!!

Edit:

POSSIBLE SOLUTION

I have found a solution - but I am worried it is not safe.......

If I enclose both calls in a timeout as shown below, the handleOpenURL fires and passes the URL as needed.

But relying on timeouts does not appear to be a safe way of getting this to work - or is it ?
Surely the device memory, execution speed etc will play a part in whether this work around will work for every device ?

<script>
function handleOpenURL(url) {
 function handleOpenURL(url) {
  setTimeout(function() {
    alert("passedURL: " + url);
             <All my parse code goes here>
  }, 4000);
}
function onLoad() {
 setTimeout(function() {
     document.addEventListener("deviceready", onDeviceReady, false);
     }, 500);
}

So working, but maybe not production strength - anyone able to help with a more robust solution?

handleOpenURL is not called if app was closed

I'm trying to launch my app with link on Facebook feed. If my app was opened at that time and just staying in background (deviceready already happened), everything is OK, handleOpenURL works. But if my app was closed, I get nothing. Java is trying to call handleOpenURL, which does not exist in that moment because my first page is not loaded. It could happen because I use splash-screen. Could you call handleOpenURL only after deviceready event?

Parsing with handleOpenURL

Can you point me to a good resource for best practice and parsing the url from your plugin?

example "myapp://param?id=1234&msg=hello"

ERR_UNKNOWN_URL_SCHEME

Hi there,

I'm creating a new cordova project in visual studio hybrid tools CTP 2. I've created the plugins folder and put the LaunchMyApp plugin into there, compilation failed as I hadn't set the URL_SCHEME protocol.

So I modified the plugin.xml file so that the preference element for URL_SCHEME is now a param element with a value attribute set to "test".

The app compiles and launches and in the index page that shows I have put the following code,

Open

the problem is once clicked, I receive an ERR_UNKNOWN_URL_SCHEME error, and the alert in my app doesn't fire. I'm running it in the android sdk emulator.

Any idea what I've done wrong or am missing?

Android App opening inside Chrome after clicking the customscheme://

I've got my app opening from a link perfect on iOS, on Android when I click the custom link ("sample://โ€) it launches my app, however, if I look at the task switcher, my app isn't listed. Instead, Chrome is shown, with my app's screen shot.

screenshot_2014-06-17-08-57-29

Update:

Cordova 3.1
Nexus 4/Android 4.4
Nexus 7/Android 4.4.3

handleOpenURL Problems After Moving to PhoneGap v3.5.0 and/or v3.6.3

Hi,
When using PhoneGap Build v3.3 with no settings for launchMode or reference to xmlns:android in config.xml I could start a web browser from within my app using "window.open". From a web page within the web browser I could LaunchMyApp and read the passed URL. However this would open up a new instance of my app each time. But I was okay with that.

My index.html auto calles main.html where all my code sits.
I have place function handleOpenURL(url) {} script inside the html head.
(Is this the correct place for it?)

With PG v3.3 all seems to work fine, I get passed the URL and can read the passed parameters.

HOWEVER

I am now building the same app with PhoneGap v3.5.0 and/or v3.6.3 (I have tried both)

LaunchMyApp works every time BUT I cannot read the URL.

I have added in config.xml:
xmlns:android = "http://schemas.android.com/apk/res/android"

AND tried different combinations of and as suggested in other posts:

/gap:config-file

I have tried "singleTop" and "singleTask" and "standard"

But whatever combination I try I cabnnot read the passed URL - it is as if the handleOpenURL is not being triggered.

I may simply be not placing handleOpenURL in the correct part of my project!!

Summary:

My Config.xml


MY NAME/name>
DESCRIPTION HERE
<author href=" AUTHOR DETAILS
(also tried with 3.5.0)

/gap:config-file # My Main Project Code: <title>My Project</title> function handleOpenURL(url) { setTimeout(function() { alert("passedURL: " + url); }, 600); } </script>

Is there something obvious wrong with the approach above that is causing handleOpenURL to not work?

Maybe I need to call it somewhere else in my project in in a different way ?

Many thanks.

Redundant Entries being added in Project-Info.plist

There are redundant entries from this plugin being added in Project-Info.plist

Every time I build, the following code gets added over and over ( FYI, the launch protocol I am using is "facing" ). Even if you delete the entries, every time you build, they get added again. The result for my actual app is pasted below.

What should be this:

   <array>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
    </array>

Ends up looking like this:

   <array>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>facing</string>
        </array>
      </dict>
    </array>

handleOpenURL not fired when from deep-linkink (ElementWave Push)

Hello Eddy, first thank you for your plugs, I used some of them and it's pretty usefull !

I'm trying to catch some value from elementwave push to redirect user to the correct page when he press the push. ElementWave provide a deeplink field that permit to do this kind of thing so thats why i need your plugin

When i launch via an email link, the handleOpenURL fire perfectly, however, via the push, the app is launched but handleOpenURL not fire, like I've not provided the deeplink...

Here some info :
Cordova 3.6
tested on Android 4.2.1
not tested yet on Ios

How to reproduce:
-create free account on http://www.elementwave.com/
-download and install the plugin with CLI : plugin
-add some js code to implement device resume and pause event like they said in the integration doc provided
-send a new push with your deeplink

Here is my code :

function handleOpenURL(url) {
                setTimeout(function() {
                    alert("received url: " + url);
                }, 0);
            }
            var app = {
                // Application Constructor
                initialize: function() {
                    this.bindEvents();
                },
                // Bind Event Listeners
                //
                // Bind any events that are required on startup. Common events are:
                // 'load', 'deviceready', 'offline', and 'online'.
                bindEvents: function() {
                    document.addEventListener('deviceready', this.onDeviceReady, false);
                    document.addEventListener('pause', this.onPause, false);
                    document.addEventListener('resume', this.onResume, false);
                },
                // deviceready Event Handler
                //
                // The scope of 'this' is the event. In order to call the 'receivedEvent'
                // function, we must explicity call 'app.receivedEvent(...);'
                onDeviceReady: function() {
                    app.receivedEvent('deviceready');
                },
                onPause: function() {
                    app.receivedEvent('pause');
                },
                onResume: function() {
                    app.receivedEvent('resume');
                },
                // Update DOM on a Received Event
                receivedEvent: function(id) {
                    if (id == 'deviceready'){
                        console.log('Received Event: ' + id);
                        app.waveInit();
                        initialize()//launch the app process
                    }

                    if (id == 'pause')
                    {
                        app.wavePause();
                    }

                    if (id == 'resume')
                    {
                        app.waveResume();
                    }
                },
                waveInit: function()
                {
                    var elementWave = cordova.require("com.elementwave.ElementWave");

                    //elementWave.init("USER_KEY", "APP_KEY", "GCM_PROJECT_NUM", function(retValue)
                    elementWave.init("xxx", "xxx", "xxx", function(retValue)
                                    {

                                    });

                    elementWave.resume(function()
                        {
                        });
                },
                wavePause: function()
                {
                    var elementWave = cordova.require("com.elementwave.ElementWave");
                    elementWave.pause(function()
                    {
                    });
                },
                waveResume: function()
                {
                    var elementWave = cordova.require("com.elementwave.ElementWave");

                    elementWave.resume(function()
                    {
                    });
                }
            };
            app.initialize()

I'm really stuck on this so I apreciate any idea...

Great Plugin, but what would happened if the app is not installed.

Hi,

I have app name com.rk.master and i named the app's URL_SCHEME as comrkmaster.

Now i have a another app com.rk.test, and from the test app, i have <a> tag to open my master app. and its opening perfectly.

But what i want is, if the master app is installed then it should open, or else it should goto google playstore, or apple iTunes Store. How to do that with this Plugin. Please help me.

Launch my app in new process

I have 2 Phonegap apps, A and B. I want to be able to launch B from A and A from B. Using the InAppBrowser, I do window.open(url, "_system") . It works but (at least in Android, not tested in iOS) it doesn't start a new process. So if I run A, then start B from A, in the list of processes I only see A (which actually is now B).

I would like instead to see both A and B in the list of processes. Of course, if A or B is already started, I wouldn't want to launch another process.

I don't know if that's possible to achieve with this plugin.

Trouble using the plugin

Hello,

I'm developing a PhoneGap application and I need to just launch another application called UnTappd from a link. I've done the following but still get a protocol error when clicking the 'open' button.

Installed the plugin:
$ cordova plugin add https://github.com/EddyVerbruggen/LaunchMyApp-PhoneGap-Plugin.git --variable URL_SCHEME=untappd

Updated my config.xml:
<.gap:plugin name="nl.x-services.plugins.launchmyapp">
<.param name="URL_SCHEME" value="untappd" />
<./gap:plugin>

Added a button in my app: (Brewing Up A Cure)
<.button onclick="window.open('untappd://', '_system')">Open the other app

Rebuilt android:
phonegap build android

Installed:
phonegap install android.

I click on the link and get the same error as always (protocol not supported). This is on Phonegap 3.3.0.

Is there something obvious I'm missing?

Phonegap Build missing URL

I saw issue #11 but unlike that one I don't have a typo
When building I get following error on iOS (not on android)

Error - One of your plugins requires a parameter: URL_SCHEME - You can fix this here

from my config.xml

    <gap:plugin name="nl.x-services.plugins.launchmyapp" version="3.1.1">
        <param name="URL_SCHEME" value="theappnamehere" />
    </gap:plugin>

I opened a ticket here however I'm not too hopeful on that front.

Thanks for the support!

Android handleOpenURL not working

I am using this plugin with phonegap + sencha touch combination. The app opens when a link is clicked but the handleOpenURL is not invoked.

I added document.addEventListener("pause", function(){navigator.app.exitApp()}, false); but still handleOpenURL is not invoked.

Tested this on the genymotion emulator and s4.

Thanks,

Multiple CFBundleURLSchemes in *-Info.plist

I'm using your plugin for iOS and it works perfectly. Thank you for such an easy setup!

But I noticed something odd. It seems that every time I start my app using the custom URL scheme, the following code snippet is added several times to the *-Info-plist. At the moment it's over 400 times in there.

<dict>
  <key>CFBundleURLSchemes</key>
  <array>
    <string>myUrlScheme</string>
  </array>
</dict>

I'm using your plugin with Cordova 3.5.0. Thanks!

Click on URL when app is already running

Hi, first I wish to thank you for this great plugin.

My issue is this: when my app is already running and the user clicks on some link to relaunch it, the app is brought to the top again, but the "handleOpenURL" is not called.

After some investigation I verified that your plugin call the error callback with this message: "App was not started via the launchmyapp URL scheme. Ignoring this errorcallback is the best approach.". So if the app is already running, when I click on some link, it brings it to top but without getDataString() value.

My app is singleInstance, but I can change that if is this an issue.

Thanks a lot.

Android "hangs weirdly" in executing handleOpenURL(url)

On my Android LG, if i click on a custom url scheme link with parameters. The App opens fine but the handleOpenURL(url) seems like it is not triggered.

But...
If i then lock the screen and open the screen again, the app resumes and executes handleOpenURL(url) fine with all parameters to.

I am using phonegap build
I am running SingleTop on android
I am testing it with Android LG (Android 4.1.2)

The plugin is working perfect on IOS.

Any ideas? Have you heard about it before?

EDIT:
Also testet now on samsung galaxy s4. Same issue.
I had to publish the app to the store now with this bug.

So you are welcome to test the issue. Its out there LIVE :(

Recreate problem:

  1. Download app
    https://play.google.com/store/apps/details?id=me.mobione.coolbox
  2. Click on this invite link from your android device and app opens... but handleOpenURL(url) doesnt fire.
    coolbox://?name=andreas&time=1401891091637&t=i
  3. Lock the screen and unlock the screen and the handleOpenURL(url) fires and everything is great!!??

I am really stuck here

How to handle the URL after the app starts?

I found this in the doc. But I cannot understand how this function gets fired. How do I call the handleOpenURL function?

function handleOpenURL(url) {
console.log("received url: " + url);
}

handleOpenURL is not getting called on Android

Here is a simple test case that shows that handleOpenURL is not getting called on Android.

  1. Create a Cordova app and add the LaunchMyApp plugin:

    cordova create abc
    cd abc
    cordova platform add android
    cordova plugin add https://github.com/EddyVerbruggen/LaunchMyApp-PhoneGap-Plugin.git --variable URL_SCHEME=mycoolapp
    
  2. Edit www/index.html to be the following:

    <!DOCTYPE html>
    <html>
    <head>
        <title></title>
        <script>
            handleOpenURL = function (url) {
                setTimeout(function(){
                    window.foo = 'The url is ' + url;
                },0);
            };
        </script>
    </head>
    <body>
        <a href="#" onclick="alert(window.foo);">Alert the value of "foo"</a>
    </body>
    </html>
    
  3. Run the app.

    cordova run android
    
  4. Go to the browser and visit this page.

  5. Click the link in that page. You will be taken to the app.

  6. Click "Alert the value of "foo"".

// Expected: The alert dialog shows "The url is mycoolapp://index.html?foo=bar".
// Actual: The alert dialog shows "undefined".

This does work on iOS, just not Android.

The protocol isn't supported. (apreceiver://)

Hello

First I would like to say that your app works, I created a webpage added to and soon as I click it via Chrome, Firefox, Native on Android it works.

So then I tried to do this.
I have 2 apps. One is called AppLauncher and other is called AppReceiver. Basicalhy I want that when I click the button on AppLauncher that has a <.a href="apreceiver://">Open App<./a> but it gives me "The protocol isn't supported. (apreceiver://)."

I tried to add to the config but no luck, I'm more an artist than programmer.
Is there anyway I could achieve this with your plugin or did I forgot to add something?

Please let me know.
Using Android Tablet with 4.1 on it.

Cheers
Mooga

PhoneGap Build : malformed config.xml

I am using PhoneGap 3.3.0 via PhoneGap build. I also tried 3.1.0.

When I include this in my plugins section of config.xml

    <gap:plugin name="nl.x-services.plugins.launchmyapp">
      <param:name="URL_SCHEME" value="ecosystem" />
    </gap:plugin>   

then PhoneGap build errors out with "malformed config.xml"
image

But if I remove only that and change nothing else, it compiles just fine.

handleOpenURL Problems After Moving to PhoneGap v3.5.0 and/or v3.6.3

Hi,
When using PhoneGap Build v3.3 with no settings for launchMode or reference to xmlns:android in config.xml I could start a web browser from within my app using "window.open". From a web page within the web browser I could LaunchMyApp and read the passed URL. However this would open up a new instance of my app each time. But I was okay with that.

My index.html auto calles main.html where all my code sits.
I have place function handleOpenURL(url) {} script inside the html head.
(Is this the correct place for it?)

With PG v3.3 all seems to work fine, I get passed the URL and can read the passed parameters.

HOWEVER

I am now building the same app with PhoneGap v3.5.0 and/or v3.6.3 (I have tried both)

LaunchMyApp works every time BUT I cannot read the URL.

I have added in config.xml:
xmlns:android = "http://schemas.android.com/apk/res/android"

AND tried different combinations of and as suggested in other posts:

<preference name="AndroidLaunchMode" value="singleTop" />
<gap:config-file platform="android" parent="/manifest/application"> 
      <activity android:launchMode="singleTop" />
</gap:config-file>

I have tried "singleTop" and "singleTask" and "standard"

But whatever combination I try I cabnnot read the passed URL - it is as if the handleOpenURL is not being triggered.

I may simply be not placing handleOpenURL in the correct part of my project!!

Summary:

My Config.xml

<widget xmlns = "http://www.w3.org/ns/widgets"
                xmlns:gap = "http://phonegap.com/ns/1.0"
        xmlns:android = "http://schemas.android.com/apk/res/android" 
        id = "MY ID HERE"
                version = "2.0.1">
<name>MY NAME/name>
<description> DESCRIPTION HERE </description>
<author href=" AUTHOR DETAILS </author>
<preference name="phonegap-version" value="3.6.3" />           (also tried with 3.5.0)

<!-- 3.6.3 & 3.5.0 fail to pass URL, Also tried the following preference & activity in different combinations -->

<preference name="AndroidLaunchMode" value="singleTop" />
<gap:config-file platform="android" parent="/manifest/application"> 
      <activity android:launchMode="singleTop" />
/gap:config-file```
# My Main Project Code:

`````` <head>
<meta charset="utf-8">
<title>My Project</title>
<link href="jquery-mobile/jquery.mobile-1.4.2.min.css" rel="stylesheet" type="text/css"/>
<link href= all the other link files.......
<script>
function handleOpenURL(url) {
  setTimeout(function() {
    alert("passedURL: " + url);
             <All my parse code goes here>
  }, 600);
}
</script>
</head>```

Is there something obvious wrong with the approach above that is causing handleOpenURL to not work?

Maybe I need to call it somewhere else in my project in in a different way ?

Many thanks.

Cannot catch URL if previous session is expired

The handleOpenURL is doing fine if the session is still valid, but when the session is expired, it's still able to launch my app but the handleOpenURL is not called, hence cannot catch the URL

handleOpenURL not triggered when application is working in background

Sometimes when application is working in background opening it using custom URL doesn't trigger application to start again but instead it resumes.

In this case when application is resumed using custom URL scheme, handleOpenURL doesn't get triggered and I'm unable to catch the URL I'm sending to the application.

Also it is strange that sometimes the application is resumed and sometimes it is started again when using custom URL scheme to open it.

function handleOpenURL(url) {
setTimeout(function () {
alert("received url: " + url);
}, 0);
};

Get error when installing for iOS

Works for android but I get this issue when installing for iOS via: cordova plugin add https://github.com/EddyVerbruggen/LaunchMyApp-PhoneGap-Plugin.git --variable URL_SCHEME=mycoolapp

Installing "nl.x-services.plugins.launchmyapp" for ios
Failed to install 'nl.x-services.plugins.launchmyapp':undefined
undefined

Trouble with singleTask.

Hi, I'm not able to get URL params with singleTask mode. LaunchMyApp is returning error callback, seems getDataString() is null.

Can you tell me something about this?

Thanks!

Sorry for my english.

How to add a host?

How can I add a host to watch for?

This code:
data android:host="mysite.com" android:path="/hi" android:scheme="http"

But it doesn't work.

support for HTTP URI scheme or intents?

Hi,

Thank you for the plugin. Its been awesome so far.

However, I have a question as I try to understand if/how I could use this plugin to solve a problem:
Lets say I have a link on my mobile website that uses the custom URL scheme eg. test://. For users that have the app installed, it will open the app and pass on the URL to the app. But, what if they don't have the app installed, I tried opening a random URI (test://something.com/param=test) in iOS simulator and got an error --> "Safari cannot open the page because the address is invalid). I also tried test://www.google.com/ but same error.

It looks like the solution is at http://stackoverflow.com/a/3472228/3527396. Can I somehow use your plugin with the solution mentioned in the link above?

Please let me know if you have any better ideas.

Thanks.

Opening App from SMS / WhatsApp / Browser

Hello,
i was wondering if opening an app by custom url via the system browser url bar is
possible under android.
same question goes for whatsapp or sms messages. they open the browser
but unfortunately the browser trys to "google" the request instead of opening the app.
The url scheme has been registered with the system correctly, which i know since
a href="rdels://test" link on an external page works out fine.
same code works for ios perfectly. since we don't want to be dependent on an internet connection the href linking isnt an option unfortunately.

thank in advance

PhoneGap Build does not launch

I have created an App and followed the instructions;

  1. Added the config.xml content as below

    < gap : plugin name="nl.x-services.plugins.launchmyapp">
    < param name="URL_SCHEME" value="mycoapp" />
    < / gap:plugin>

I add LaunchMyApp.js reference on my code but did not add it..
Hydration is NOT enabled

but nothing happens when I click this link from another page
< a href="mycoapp://">Open my app</ a>
Webpage not Avaiable

Please let me know if I have missed something am testing on Android 4.4

Open the app "again" instead of resuming it

I really don't know how to explain this one, let me try this way :

App -> Browser -> App

so, I'm passing data through a URL with the "InAppBrowser" plugin to device's browser (I'm using Chrome for Android), after data process is done, I'm trying to bring the result back to the app with a "Custom URL Theme". it is working though, but instead of resuming the previous working-on-background app, it launches the app "again" so there's two same application running now.

I'm currently working with Android. Can you help me with this ?
thank you :)

Using the custom url plugin with the charnekin modular framework

Hi there,

I'm trying to use this plugin with the charnekin modular framework found here,

https://github.com/charnekin/api

I can get the custom url protocol to work outside of the framework, but inside i just get a blank screen after clicking the url, any idea how to proceed?

I've placed alert code in the index.html file of the charnekin framework, this is fired through normal invocation and url invocation ut the registered url handler doesn't fire.

BTW, sorry for cross posting, i'm not entirely sure where the issue lies and need to proceed as soon as I can.

Chrome for Android does not redirect to App via Link

I use Android 4.1.2. and use the following JavaScript im my page to redirect to the app:

        var baseUrl = // my baseurl;
        var customUrlPrefix = "myapp://";
        var customAppUrl = document.URL.substring(baseUrl.length + 1);
        if (customAppUrl.length == 0) {
            customAppUrl = customUrlPrefix;
        }
        else {
            customAppUrl = customUrlPrefix + customAppUrl;
        }

        var redirect = function (location) {
            var iframe = document.createElement('iframe');
            iframe.setAttribute('src', location);
            iframe.setAttribute('width', '1px');
            iframe.setAttribute('height', '1px');
            iframe.setAttribute('position', 'absolute');
            iframe.setAttribute('top', '0');
            iframe.setAttribute('left', '0');
            document.documentElement.appendChild(iframe);
            iframe.parentNode.removeChild(iframe);
            iframe = null;
        };

        window.onload = function() {

            // check the visiblility of the page
            var hidden, visibilityState, visibilityChange;

            if (typeof document.hidden !== "undefined") {
                hidden = "hidden", visibilityChange = "visibilitychange", visibilityState = "visibilityState";
            }
            else if (typeof document.mozHidden !== "undefined") {
                hidden = "mozHidden", visibilityChange = "mozvisibilitychange", visibilityState = "mozVisibilityState";
            }
            else if (typeof document.msHidden !== "undefined") {
                hidden = "msHidden", visibilityChange = "msvisibilitychange", visibilityState = "msVisibilityState";
            }
            else if (typeof document.webkitHidden !== "undefined") {
                hidden = "webkitHidden", visibilityChange = "webkitvisibilitychange", visibilityState = "webkitVisibilityState";
            }


            if (typeof document.addEventListener === "undefined" || typeof hidden === "undefined") {
                // not supported
            }
            else {
                document.addEventListener(visibilityChange, function() {
                    switch (document[visibilityState]) {
                    case "visible":
                        // open app if page gets visible again
                        redirect(customAppUrl);
                        break;
                    case "hidden":
                        break;
                    }
                }, false);
            }

            if (document[visibilityState] === "visible") {
                redirect(customAppUrl);
            }
        };  

It works great on iOS 7.1.1. and on the the native Browser of my Android 4.1.2 device. But it does not redirect to the app on Chrome for Android.

I tried to access

mycoolapp://

Did I miss something?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.