Software Archive
Read-only legacy content
17060 Discussions

Custom URL Scheme and Trouble with Cordova Plugin

Barry_Johnson
New Contributor I
2,077 Views

I would like to implement support a custom URL scheme for my XDK-built application. Current focus is building for Android using Crosswalk, although will also target iOS as soon as the app is feature-complete. As a detail I am using the current XDK (version 1995) on Windows 8.1.

By custom URL scheme, to be clear, I mean support for launching the app via a URL like "mycoolapp://dosomething" via a web page or another application.

Eddy Verbruggen, author of many Cordova plugins, has a plugin called "LaunchMyApp", the GitHub repo of which is at: https://github.com/EddyVerbruggen/Custom-URL-scheme and the Cordova reigstry page is at: http://plugins.cordova.io/#/package/nl.x-services.plugins.launchmyapp

I have attempted to integrate this plugin with my XDK project, but am not able to get very far.

I have attempted to include the plugin via:

1) Reference to the plugin ID and checking the box indicating the XDK should get it from the Cordova registry.

2) Reference the Github repo for the plugin (i.e. leave the above-mentioned box unchecked).

3) Install from a local copy of the downloaded repo.

Because testing this in any way would require a built app, I have then attempted to build the app. Regardless of which of the techniques above I employ to include the plugin, the result is the same: the build fails but a link to a detailed build log is not provided. The displayed results are shown below. Note that I am not using the ionic keyboard plugin, but included it just to see if something was flaking out with plugins generally, and since it was the top-downloaded plugin that I wasn't already using,

In any case, I already expected there would be some monkeying around involved with getting the plugin to work properly based on the discussion of its manual installation process and the fact that I have not found clear documentation on the details of using plugins in the XDK (for example, not documentation around the correct use of the "paramvals" element of a plugin's configuration data in the cordovaPlugins element of the *.xdk configuration file. For example, the android config files need to have the URL scheme specified (maybe this can come through paramvals, but without doc, I don't know).

So my questions are as follows:

1) Is there an XDK sample available anywhere making use of a custom URL scheme? I have looked but not found one. If there is a working example, that is probably sufficient - I can probably sort it out from there.

2) Any ideas why the plugin above may be troublesome - even just to include it? It was last updated three months ago, and I think there is little question the plugin author generally knows how to build plugins, so I'm not inclined to simply blame the plugin.

3) Is there any comprehensive and detailed documentation about using Cordova plugins in the XDK? Please note the words "comprehensive" and "detailed" - there is ample documentation available for the basic usage scenarios, an additional link to which will not be helpful at the present time.

I have the Cordova CLI installed but have been reluctant to use that as an approach here as I am not sure how the two tools' (XDK vs Cordova CLI) standard behaviors may influence or conflict with each other and I am very committed to Crosswalk.

Happy to use other tools to get the desired results, but the ideal will allow me to continue using the XDK as the main driver of my build process.

Thanks!!!

Edit: This may be (and I be most likely is) related to a more general set of problems being observed regarding third-party plugins and Crosswalk builds. Please also note issues at: https://software.intel.com/en-us/forums/topic/560376, https://software.intel.com/en-us/forums/topic/560442.

Interestingly, I see from Gary H's comment on: https://software.intel.com/en-us/forums/topic/560258 that at least on June 19th, it appeared he was successfully including the LaunchMyApp plugin (but was tripped up by a different one). The plugin has not been updated in the intervening period.

0 Kudos
1 Solution
Gary_H_2
New Contributor I
2,077 Views

Hi Barry, yes i am using the custom URL plugin you mentioned and everything was working fine until a few days ago. I'm still trying to get to the bottom of why my crosswalk builds stopped working but I can certainly help you out while I'm waiting. I tried all the same methods as you and then in the end had some luck by including the following at the end of my intelxdk.config.crosswalk.xml file:-

<intelxdk:plugin xmlns:intelxdk="http://xdk.intel.com/ns/v1" intelxdk:name="LaunchMyApp" intelxdk:value="https://github.com/EddyVerbruggen/LaunchMyApp-PhoneGap-Plugin.git">
<intelxdk:param intelxdk:name="URL_SCHEME" intelxdk:value="mycoolapp"/>
</intelxdk:plugin></widget>

I then have this at the top of my index.html file:-

    <script type="text/javascript">
             
        var handleOpenURL = function(url) {
            console.log("RECEIVED LINK: " + url);           
            window.localStorage["link"] = JSON.stringify(url);
        };

    </script>

You can then click on a link in your browser such as mycoolapp://dosomething and this will cause your app to be launched and the function will be called. I'm monitoring local storage with a timer and when I see something in the link I jump to the page that handles it. Hope this helps.

View solution in original post

0 Kudos
10 Replies
Gary_H_2
New Contributor I
2,078 Views

Hi Barry, yes i am using the custom URL plugin you mentioned and everything was working fine until a few days ago. I'm still trying to get to the bottom of why my crosswalk builds stopped working but I can certainly help you out while I'm waiting. I tried all the same methods as you and then in the end had some luck by including the following at the end of my intelxdk.config.crosswalk.xml file:-

<intelxdk:plugin xmlns:intelxdk="http://xdk.intel.com/ns/v1" intelxdk:name="LaunchMyApp" intelxdk:value="https://github.com/EddyVerbruggen/LaunchMyApp-PhoneGap-Plugin.git">
<intelxdk:param intelxdk:name="URL_SCHEME" intelxdk:value="mycoolapp"/>
</intelxdk:plugin></widget>

I then have this at the top of my index.html file:-

    <script type="text/javascript">
             
        var handleOpenURL = function(url) {
            console.log("RECEIVED LINK: " + url);           
            window.localStorage["link"] = JSON.stringify(url);
        };

    </script>

You can then click on a link in your browser such as mycoolapp://dosomething and this will cause your app to be launched and the function will be called. I'm monitoring local storage with a timer and when I see something in the link I jump to the page that handles it. Hope this helps.

0 Kudos
Barry_Johnson
New Contributor I
2,077 Views

Hi Gary - Thanks so much for your reply. It is heartening to know that it will work fine once the build issue gets sorted out, which I have every confidence will be at least relatively soon. Also glad it appears as simple to integrate as I had expected from reading the doc, although I thought maybe the URL scheme parameter might alternately be defined in the master xdk config which would then modify/regenerate the various platform.xml files., so thanks as well for the clarification on the need for direct modification of the crosswalk.xml file.

I thought it would be a quick win for a specific use case a colleague had raised. Looks like it will be shortly.

Thanks again!

0 Kudos
Gary_H_2
New Contributor I
2,077 Views

To clarify, I actually changed intelxdl.config.additions and then XDK updated the platform specific configs. 

0 Kudos
Barry_Johnson
New Contributor I
2,077 Views

Thanks for the additional detail. Even after the build issue is resolved your instructions will hopefully be useful to others as well.

0 Kudos
Mark_B_3
Beginner
2,077 Views

Hi, 

Has anyone got an update on this.

I am getting the same issue as Barry.  It's working fine for an iOS build, but failing for Android Crosswalk.

Anyone from Intel care to comment?

0 Kudos
PaulF_IntelCorp
Employee
2,077 Views

@Mark -- can you provide the detailed build error log? Attach it to your a post as a text file.

0 Kudos
Mark_B_3
Beginner
2,077 Views

Hi Paul,

There is no build error log.  I get the same problem Barry reports at the start of this thread.  The build just errors without producing a log file. See attached screenshot.

Mark.

0 Kudos
Barry_Johnson
New Contributor I
2,077 Views

Just as a quick update from me (I have been traveling or would have chimed in earlier) - I have not yet returned to this issue to try to get it working with the latest XDK. I am planning to return to it next week and will report back any new results.

0 Kudos
PaulF_IntelCorp
Employee
2,077 Views

@Mark -- your build log shows a blank for the App ID -- did you black it out or is this correct? Also, did you try removing each plugin, one-by-one, to see if one of those is causing a problem. I don't see any in the list that I suspect, but this is usually the source of these problems. Do all the plugins you have included show up in that list? If not, then a missing plugin (from that list) is likely the culprit...

0 Kudos
PaulF_IntelCorp
Employee
2,077 Views

Hi Paul,

Thanks for responding to me.  I blacked out the app id.

I tried removing other plugins as you suggested and discovered that (in my case at least) the fault is not with the LaunchMyApp plugin as we suspected, but with Dan Wilson's Google Analytics Plugin (which you can find here: https://github.com/danwilson/google-analytics-plugin)

If I remove that plugin the build works fine.

Looking at the GitHub documentation for The GA plugin, it says there is a known issue with v 0.8 of the plugin and Crosswalk 5+.  The workaround is to use 0.6.1 of the plugin. 

Having done this, my build now works. Thanks for the pointers.

Mark.

P.S. Sending you a private message on this, as at the moment there is something called Mollum captcha which is blocking me adding anything new to the forums :(

Thanks for the update, Mark. So the problem plugin is one that was not listed in the build log that you showed in your image.

p.s. I've seen several people having trouble with the new captcha, I'll let our forum ops know, they had to tighten it up due to a big spam storm we encountered a while back. Not sure if they can loosen the reigns or not...

 

0 Kudos
Reply