nordnet/cordova-universal-links-plugin

Does this plugin work with Phonegap Build?

Closed this issue ยท 71 comments

I can't seem to get this to work for Phonegap Build for iOS 9.2. Are the entitlements getting set correctly with PGB?

When I add my .ipa file into
https://limitless-sierra-4673.herokuapp.com/

it complains: Must be able to find entitlements. I looked and there is no archived-expanded-entitlements.xcent at the root of the app contents.

Has anyone got it to work with Phongap Build. Or am I missing something?

Sorry for long answer.

Never tried it with Phonegap Build, so can't tell. Entitlements file is generated by cordova hooks, that are in this plugin. So maybe they are not executed properly. Are there any build logs that can help?

Also, entitlements file is stored in Resources folder of the Xcode project. Maybe validator expects it to be in the root, doesn't find it there and complain? You can try to install .ipa file on your test device and check, if UL is really working. To install it - use iOS device and iTunes on your Mac/Windows machine.

Regarding the link you provided. Well, there is another plugin, that had problems with Phonegap Build: nordnet/cordova-hot-code-push#68 . It is also on npm, uses cordova hooks and native code. But the problem was that Phonegap Build didn't include gradle files from the plugin. This was resolved by adding one line in projects config.xml (not the plugins).

So I would say, that plugin should be installed in your app, hooks should be executed. I'd suggest to check if UL really doesn't work by installing builded .ipa, and look for build logs. I'll check the docs for Phonegap Build.

Hey @nikDemyankov Thank you for the reply!

It's not working when I build it with Phonegap Build. When I open the .ipa and view the .app contents, I see that the plugin's JavaScript code is installed correctly, but I don't see any other entitlement files. When I test the .ipa on my iPhone 6 with iOS 9.2, links are not opening the app. I have Associated Domains in my provisioning profile. And I have an apple-app-site-association file being served correctly.

Another clue... When I tried to load the IPA to iTunes via Application Loader I got this error:

ERROR ITMS-90046: "Invalid Code Signing Entitlements. Your application bundle's signature contains code signing entitlements that are not supported by iOS. Specifically, the value '*' for key 'com.apple.developer.associated-domains' in 'Payload/Vimify.app/Vimify' is not supported."

It's like there are no associated domains are being added from the <universal-links> tag...?

Thanks for the logs. I think I found the problem.

According to the logs - PGB (Phonegap Build) doesn't execute plugins JS hooks. It installs the plugin, but after that - just builds the project. Normally in Cordova projects they are executed before the actual build. They task it to configure iOS project and generate entitlements file before the build.

According to the comment from the question about PGB support for Cordova hooks we can see, that they doesn't support them. That's why no entitlements file is found. There are also similar requests in PGB: here and here. I'm afraid, there is nothing I can do about it: it's a PGB issue.

Although, you can try to tweak it:

  1. Create [PROJECT_NAME].entitlements file in your projects root directory. For example, Vimify.entitlements.

  2. Put in it the following:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
        <key>com.apple.developer.associated-domains</key>
        <array>
            <string>applinks:[YOUR_HOST]</string>
            </array>
    </dict>
    </plist>

    Replace [YOUR_HOST] with your hostname. For example:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
        <key>com.apple.developer.associated-domains</key>
        <array>
            <string>applinks:foobar.com</string>
            </array>
    </dict>
    </plist>
  3. In the projects config.xml add the following:

    <platform name="ios">
        <resource-file src="[PROJECT_NAME].entitlements" />
    </platform>

    For example:

    <platform name="ios">
        <resource-file src="Vimify.entitlements" />
    </platform>

So, the idea is to manually create entitlements file and tell PGB to copy it in the project. Maybe this would work, because that is close to the thing, that hooks are doing.

But this is iOS-only hack.

I followed your instructions above. And built my IPA using PGB. I loaded my resulting IPA into this universal link validator: https://limitless-sierra-4673.herokuapp.com/ I get this errors:

Must be able to find entitlements (looking in VimifyDev/Payload/VimifyDev.app/archived-expanded-entitlements.xcent)

Should I change the file name from Vimify.entitlements to archived-expanded-entitlements.xcent?

Trying that now...

Another problem is that PGB won't put the entitlements file at the root of the .IPA. It seems that the <resource-file> tag is not copying the file from www folder into the root of the IPA.
Here's is an issue on phonegap's build repo:
phonegap/build#472

No, you don't have to change the name to archived-expanded-entitlements.xcent, that would not work. It should not, at least.

If PGB doesn't support cordova hooks and there is no way to include custom resource files - then I guess there is nothing that can be done at the moment...

Closing it, since this is a PGB issue, nothing can be done at the moment.

@benmcmaster were you able to discover a workaround to get the plugin working with Build?

@jskrepnek No. Not using Universal Links yet with my app. I just pointed all my links in emails and such to a redirect page that called a customURL. It's ghetto and one extra tap for the user... but it works for now. I am very close to just using Xcode to build my app. I am hoping PGB will add the features needed to get this working.

Phonegap Build support now Cordova Hooks :
http://stage.docs.phonegap.com/tutorials/configure/04-using-hooks/

Your plugin should be compatible with Phonegap Build

@VanVan Do you mean that this plugin should just work in it's current state? Or is there any work that needs to be done?

@benmcmaster I think it should work as it is. Only concern is that I had some reports, that PGB removes custom tags from the config.xml. If it's not gonna do that - it should be fine.

I would love to know if anyone has got this plugin working with PhoneGap Build? If so did you do anything special to get it working with iOS and Android? Thanks in advance.

Hi,
I am experiencing same issue - Any one have it working with Phonegap Build ?
Thanks
Kim

PhoneGap build needs to support this! We need a real answer why PGB wont support it.

Any news ?

Nope, I've just tried and it doesn't work with phonegap build system (and I'm using gradle, not PGB).

I think the issue is that hooks are not supported in phonegap build.
I've found these discussions on phonegap build forums (many people are trying to use this plugin with phonegap build :))
https://forums.adobe.com/message/8871386
https://forums.adobe.com/message/8976135

This is my config.xml:
https://github.com/yoav-zibin/phonegap-tictactoe/blob/gh-pages/www/config.xml
You can see I'm using gradle:
preference name="android-build-tool" value="gradle"

When I looked in the generated android manifest:
AndroidManifest copy.xml.txt
I was expecting to see:
intent-filter android:autoVerify="true"
but it's not there.

What do the hooks do exactly?
I've seen above, in comment "nikDemyankov commented on Dec 22, 2015" that the hooks modify the android manifest and ios property list. (But it mentions PGB, and I'm using gradle.)
Phonegap build has mechanisms to modify these:
http://phonegap.com/blog/2014/01/30/customizing-your-android-manifest-and-ios-property-list-on-phonegap-build/
If hooks are used just for that, then I can try to manually do these customizations and unblock a lot of people that want to use this plugin in phonegap build :)

@yoav-zibin Hooks are used to generate platform-specific preferences depending on the things you define in config.xml. The idea is that you define which links you want to handle in the app - and hooks generate all the configurations for you.

For iOS:

  • apple-app-site-association file, that you deploy on your server.
  • .entitlements file with domain settings.
  • modifies .xcodeproj settings, mainly to point native project to the entitlements file.

For Android:

  • generates settings in AndroidManifest.xml.
  • generates template/example for your web site integration.

Sure, I think that can be done manually, although hooks are really simplifying developer's life :)

But the problem with PGB is not only in the hooks. As I remember, it also removes custom tags from the config.xml. And plugin need these preferences to understand, what event to fire and send data to JS side when app is launched via the link.

Even if you configure everything manually - event is not gonna be triggered, unless you modify native code as well by defining urls in it. But yeah, everything can be done :) Although, it will require some hacking.

@benmcmaster I mean Phonegap build support now everything needed for it to works, but there are some changes to do.

  • You can use Hooks during build

    - Javascript
    - Non-Javascript via Node
    
  • You can customize AndroidManifest.xml and iOS params without Hooks

<gap:config-file platform="ios" parent="FOO"> <string>BAR</string> </gap:config-file>

<config-file platform="ios" target="*-Info.plist" parent="UISomething"></config-file>

<gap:config-file platform="android" target="AndroidManifest.xml" parent="/manifest"></gap:config-file>

  • You can transmit custom tags/params, just put it in plugin config (without gap:plugin)

<plugin name="cordova-universal-links-plugin" source="npm"> <param name="FOO" value="BAR" /> </plugin>

@VanVan That's encouraging! But, I don't quite understand your answer... Do you have this plugin working on your app built with PGB? Can you please share example config code? Thank you!

I have discussed this with PGB support - they say, and might I add I understand, that they the see hooks as a Security risk for them as you could put anything in the Hooks that messe up the Build machine.
I have asked for an alternative way to change this, and are hoping that they will implement some other way to manipulate the project entitlement file.

@benmcmaster I didn't do the change needed.
@nikDemyankov You can now include platform dependent custom resources file in merges/android, or merges/ios

We are also supporting the merges directory that enables you to include platform specific assets in your project. During build the merges directory for each platform will be copied over your www directory.

If we look at cordova-universal-links-plugin/hooks/afterPrepareHook.js
You should customize AndroidManifest.xml and iOS params without Hooks helped by gap config.xml
<gap:config-file platform="ios" parent="FOO"> <string>BAR</string> </gap:config-file>

<config-file platform="ios" target="*-Info.plist" parent="UISomething"></config-file>

<gap:config-file platform="android" target="AndroidManifest.xml" parent="/manifest"></gap:config-file>

If we look at cordova-universal-links-plugin/hooks/beforePluginInstallHook.js it seems to check dependency of

  • mkpath
  • xml2js
  • rimraf
  • node-version-compare
  • plist

If we look at cordova-universal-links-plugin/hooks/iosBeforePrepareHook.js it seems related to .entitlements file. (not required for android)

phonegap-plugin-push for example is compatible with phonegap build and removed hooks :
https://github.com/phonegap/phonegap-plugin-push/blob/master/docs/PHONEGAP_BUILD.md

Is there something on this plugin that can't be done without hooks on android ? I didn't look at .entitlements on ios, but is it really the only way to do ?

@VanVan thanks. This is very interesting. I am looking at a mountain of work to migrate our build process from Phonegap Build in the cloud to a local Cordova CLI build. I need to get Universal Links working to improve our sales funnel. @nikDemyankov, any insight on this would be amazing. @kimras, is there anyone specific working on Phonegap Build who we can tap for help on this? Thanks!

I do not know how active it is but this thread was referanced today .. here is the issue linkhttps://forums.adobe.com/thread/2202518

@VanVan @benmcmaster I don't have a PGB account, since using local build system... But yes, if everything can be done with configs - hooks are not needed. As I said before - hooks are used to modify native project configs by defining settings in one place (config.xml). If that can be done otherwise - that is good.

But besides the configs there is a problem with the native side. With UL plugin your config.xml has preferences like this:

<universal-links>
  <host name="domain.com">
    <path url="/first/path" event="first_event_name" />
    <path url="/second/path" event="second_event_name" />
  </host>
</universal-links>

But with PGB you are allowed to do it only like this:

<plugin name="com.phonegap.plugins.example">
  <param name="APIKey" value="12345678" />
  <param name="APISecret" value="12345678" />
</plugin>

So, besides writing guide on how and what to set in configs - we will need to implement an alternative way to define urls for the native side. For example, instead of preferences in config.xml - include some universal_links.json config, that holds all the preferences:

[{
    "host": "domain.com",
    "path": [{
        "url": "/first/path",
        "event": "first_event_name"
    }, {
        "url": "/second/path", 
        "event": "second_event_name"
    }]
}]

That config is loaded and used on the native side instead of xml.

I'm having the same issue described here.

@nikDemyankov do you know if phonegap strips out plugin's childs?

I think the config should be readable from the root of the widget, or either from the plugin's definition. If PGB does not strip it, we may not need to implement a separated file for this purpose.

My proposal, in case we can verify PGB does not strip it (gonna test it later):

Allow configurations to be set on universal-linksor in the plugin definition

<universal-links>
  <host name="domain.com">
    <path url="/first/path" event="first_event_name" />
    <path url="/second/path" event="second_event_name" />
  </host>
</universal-links>

OR

<plugin name="cordova-universal-links-plugin">
  <host name="domain.com">
    <path url="/first/path" event="first_event_name" />
    <path url="/second/path" event="second_event_name" />
  </host>
</plugin>

@nikDemyankov can we pass the host and path data through the plist/AndroidManifest.xml?

Confirmed just now, none of the hooks are being triggered on the PGB. Gonna check if afterPluginInstall hook is triggered.

@benmcmaster:

can we pass the host and path data through the plist/AndroidManifest.xml?

Even if you can read this files to get preferences - you not gonna be able to trigger proper events. All url's will trigger the same general event.

Plus it's not gonna work for iOS: you define domains in .entitlements file, but not setting paths anywhere in xcode project. So, again, no events. You can process them on the JS side, but my guess it would be easier to implement .json config support instead of writing hacks on JS and native sides.

@cusspvz

do you know if phonegap strips out plugin's childs?

Phonegap Build might, Cordova itself doesn't. You need to test this somehow, since I don't have a PGB account (yet, but, probably will have to create one, since people really need it's support :) ).

But according to the docs, it allows plugins to set their preferences only like that:

<plugin name="com.phonegap.plugins.example">
  <param name="APIKey" value="12345678" />
  <param name="APISecret" value="12345678" />
</plugin>

Everything else is stripped away.

@nikDemyankov I've researched a little bit and I wasn't able to run hooks at the plugin side (didn't tested yet on the "project" side).

These are the steps I think PGB runs:

  • adds platform (or has already a prรฉ-added platform since it does not describes anything on the logs)
  • installs plugins (but it won't trigger related hooks)
  • builds the app (yet, plugins aren't being called)

Next to try:

  • check if project's hook are being run

Well, it seems hooks aren't the way.
They use a plugin for building the projects (which injects certificate and bypasses hooks).

@nikDemyankov do you have any idea to allow configuration using the param on plugin?

@nikDemyankov a PGB account is free for one app under 50mb... in case that matters.
https://build.phonegap.com/plans

Thank you for your work on this plugin and helping us to get it to work with PGB.

@cusspvz

do you have any idea to allow configuration using the param on plugin?

Right now I have two ideas.
First: use json file with plugin preferences, and define file's name in the config.xml.

config.xml:

<plugin name="cordova-universal-links-plugin">
    <param name="universal-links-settings" value="ul.json" />
</plugin>

www/ul.json:

[{
    "host": "domain.com",
    "path": [{
        "url": "/first/path",
        "event": "first_event_name"
    }, {
        "url": "/second/path", 
        "event": "second_event_name"
    }]
}]

Second: just put the whole setting as one-liner as a json string:

<plugin name="cordova-universal-links-plugin">
    <param name="universal-links-settings" value="[{\"host\":\"domain.com\",\"path\":[{\"url\":\"/first/path\",\"event\":\"first_event_name\"},{\"url\": \"/second/path\",\"event\": \"second_event_name\"}]}]" />
</plugin>

I prefer the first approach since it is easier to configure and more readable. Which one do you like more?

But we still would have to write instructions on how to configure other files in the project: AndroidManifest, .entitlements.

@benmcmaster

a PGB account is free for one app under 50mb... in case that matters.

Yes, thanks, already looked at PGB prices :)

@nikDemyankov maybe both of them?

I would not go for any of them, but because of pgb api, we have no choice.

And how are you managing to include the config?
I've forked your repo, added some console.logs on hooks, re-arranged files as defined on PGB hooks docs and published it to give a try. I did everything that crossed my mind to execute hooks but unfortunately I didn't manage to have them being run.

Here are my thoughts about your config approaches:

  • json file:
    • CON: out of config.xml / separated
    • CON: included at the package resources *1
  • inline-json:
    • CON: not human readable
    • PRO: no added file *1

*1 - PGB unfortunately adds all files to the packages, at least, i didn't managed yet to exclude files.

I agree it is not ideal but I prefer the json file over the "cryptic"
config.ini, mainly as it is easier to use. But anything that would work i
am all for :-)
Thanks for your time resolving this.

On Thu, Oct 20, 2016 at 4:21 PM, Josรฉ Moreira notifications@github.com
wrote:

@nikDemyankov https://github.com/nikDemyankov maybe both of them?

I would not go for any of them, but because of pgb api, we have no choice.

And how are you managing to include the config?
I've forked your repo, added some console.logs on hooks, re-arranged
files as defined on PGB hooks docs
https://github.com/phonegap/phonegap-docs/blob/941d5679bc21a3c56a0d293454ef552e6fcb4af9/drafts/1-configure/5-using-hooks.html.md
and published it
https://www.npmjs.com/package/cusspvz-cordova-universal-links-plugin to
give a try. I did everything that crossed my mind to execute hooks but
unfortunately I didn't manage to have them being run.

Here are my thoughts about your config approaches:

  • json file:
    • CON: out of config.xml / separated
    • CON: included at the package resources *1
  • inline-json:
    • CON: not human readable
    • PRO: no added file *1

*1 - PGB unfortunately adds all files to the packages, at least, i didn't
managed yet to exclude files.

โ€”
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#28 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AEx-F5NjrDcV5zfhRLMKYYkgZmIQaeokks5q13jtgaJpZM4G4kcK
.

Kim Rasmussen
geoQuestor IVS
Tel: +45 30500110

https://www.geoQuestor.com

About:
PGB unfortunately adds all files to the packages, at least, i didn't
managed yet to exclude files.

If you put it in a directory with a file called .pgbomit then the directory
is excluded :)
On Thu, Oct 20, 2016 at 4:59 PM kimras notifications@github.com wrote:

I agree it is not ideal but I prefer the json file over the "cryptic"
config.ini, mainly as it is easier to use. But anything that would work i
am all for :-)
Thanks for your time resolving this.

On Thu, Oct 20, 2016 at 4:21 PM, Josรฉ Moreira notifications@github.com
wrote:

@nikDemyankov https://github.com/nikDemyankov maybe both of them?

I would not go for any of them, but because of pgb api, we have no
choice.

And how are you managing to include the config?
I've forked your repo, added some console.logs on hooks, re-arranged
files as defined on PGB hooks docs
<
https://github.com/phonegap/phonegap-docs/blob/941d5679bc21a3c56a0d293454ef552e6fcb4af9/drafts/1-configure/5-using-hooks.html.md

and published it
https://www.npmjs.com/package/cusspvz-cordova-universal-links-plugin
to
give a try. I did everything that crossed my mind to execute hooks but
unfortunately I didn't manage to have them being run.

Here are my thoughts about your config approaches:

  • json file:
  • CON: out of config.xml / separated
  • CON: included at the package resources *1
  • inline-json:
  • CON: not human readable
  • PRO: no added file *1

*1 - PGB unfortunately adds all files to the packages, at least, i didn't
managed yet to exclude files.

โ€”
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<
#28 (comment)
,
or mute the thread
<
https://github.com/notifications/unsubscribe-auth/AEx-F5NjrDcV5zfhRLMKYYkgZmIQaeokks5q13jtgaJpZM4G4kcK

.

Kim Rasmussen
geoQuestor IVS
Tel: +45 30500110 <+45%2030%2050%2001%2010>

https://www.geoQuestor.com

โ€”
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#28 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABzZHUbvdnJ0Ft4uynjO49x4ejxOQBBNks5q14HmgaJpZM4G4kcK
.

@yoav-zibin Thanks for the info! ๐Ÿ‘

That means, in case there isn't some kind of .pgbignore for files, the json file could only be placed into an ignored directory and I see it as a CON.

I think putting the JSON string in the config file is fine as long as the param name is verbose and it's clear in the plugin documentation what to do.

On the other hand, why would it be bad that the file is included with packaged resources (Other than the fact it's not needed after being used to pass params)?

I am leaning toward the inline JSON string. Seems like it's less of a hassle.

Okay, inline json it is :) Although, it will be a developers responsibility to generate a proper one.

@nikDemyankov Thanks for your effort on creating this plugin.
Can you please provide steps to configure AndroidManifest, .entitlements files?

@simpleekare Yes, I'll write a separate doc page about that.

@simpleekare you want me to write this docs on how to do that via PGB build, or just in general in native project?

PGB pretty please :)
I'll follow the instructions myself to add it to my PGB project and give
you feedback :)
On Fri, Nov 4, 2016 at 5:01 AM Nikolay Demyankov notifications@github.com
wrote:

@simpleekare https://github.com/simpleekare you want me to write this
docs on how to do that via PGB build, or just in general in native project?

โ€”
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#28 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABzZHX4rjH7NzhfK0MiDJ7TzjPlJ-5NIks5q6vRpgaJpZM4G4kcK
.

same here, I am happy to test it as well..

Thanks in advance
Kim

On Fri, Nov 4, 2016 at 1:27 PM, Yoav Zibin notifications@github.com wrote:

PGB pretty please :)
I'll follow the instructions myself to add it to my PGB project and give
you feedback :)
On Fri, Nov 4, 2016 at 5:01 AM Nikolay Demyankov <notifications@github.com

wrote:

@simpleekare https://github.com/simpleekare you want me to write this
docs on how to do that via PGB build, or just in general in native
project?

โ€”
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<https://github.com/nordnet/cordova-universal-links-
plugin/issues/28#issuecomment-258376005>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/
ABzZHX4rjH7NzhfK0MiDJ7TzjPlJ-5NIks5q6vRpgaJpZM4G4kcK>
.

โ€”
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#28 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AEx-FxNkEdeyy4Lh8SWFxGqpHrsW10UEks5q6ySYgaJpZM4G4kcK
.

Kim Rasmussen
geoQuestor IVS
Tel: +45 30500110

https://www.geoQuestor.com

@nikDemyankov for PGB build. I am happy to test.

Understood, will do :)

@nikDemyankov , I don't even need a doc if you have an example of a config.xml that's working on PGB :)
E.g., here is my config.xml example:
https://github.com/yoav-zibin/phonegap-tictactoe/blob/gh-pages/www/config.xml

I'm very happy to test

Hi @nikDemyankov, did you get chance to work on this?

Hi @simpleekare,
No, not much. Swamped with work right now...

No news? How can we help you?
It will be pretty cool if the plugin can work with PGB :)

@maktibab didn't have time to work on any of the github stuff lately because of the releases at work. But now it's done, so was planning to start with PGB on UL plugin first this weekend, and then continue with CHCP plugin v2. Sorry for the delay, everyone...

@nikDemyankov it's the better news I'have read from 2017! I will test your stuff as soon as I can.

@nikDemyankov everythink is okay for a test? Or you need to do dev another. Do you have a doc to use?

@maktibab In the last commit I've added code for iOS to load plugin's config from www/ul.json file. From now on native side of the plugin will try to load preferences from that config. If it doesn't exist - it will use config.xml as before. And when the plugin captures the event - it will redirect it to the web as usual. So that part is solved (for iOS for now, Android is coming soon).

To test this instead of putting preferences in config.xml - you create a www/ul.json config with the following structure:

[{
    "host": "domain.com",
    "event": "general_event",
    "path": [{
         "url": "/first/path",
         "event": "first_event_name"
    }, {
         "url": "/second/path"
    }]
}]

As you can see - it is similar to what we have right now in config.xml.

Now we need to understand how to put things in .entitlements file. I know that in Cordova iOS platform v4.3 you can add stuff to Entitlements-Release.plist and Entitlements-Debug.plist files though plugin.xml. But not sure how you can do that through the config.xml.

Also, they have messed it up a bit: these files should have extension .entitlements instead of .plist in order for Xcode to see them. They a issue for that: CB-12316. But it should work anyways. It's just a heads up for those who will open project in Xcode and not gonna see entitlement files in the project and Associated Domains feature as activated.

So now the plan is:

  1. Understand, how to add stuff to entitlement files.
  2. Implement json config loading in Android.
  3. Understand, how to add properties to the root activity in the AndroidManifest.xml.

The second one is the easiest :) One and three are the most painful since we don't have hooks support.

You can do (3) like this:
http://docs.phonegap.com/phonegap-build/configuring/config-file-element/
E.g.,
https://github.com/phonegap/phonegap-plugin-push/blob/00c67cb2c85e97dfe4f7020f28ad4d954458599f/plugin.xml#L29

I used it to remove permissions I don't use like this:
<config-file platform="android" parent="/manifest" mode="delete"> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> </config-file>

I'm not sure about (1), but I looked at a push-notification plugin that I use, and they pass the entitlement key in the .plist file like this:
https://github.com/phonegap/phonegap-plugin-push/blob/00c67cb2c85e97dfe4f7020f28ad4d954458599f/plugin.xml#L98
<config-file target="*-Debug.plist" parent="aps-environment"> <string>development</string> </config-file> <config-file target="*-Release.plist" parent="aps-environment"> <string>production</string> </config-file>

Note that aps-environment is a Notification entitlement key see
https://developer.apple.com/library/content/documentation/Miscellaneous/Reference/EntitlementKeyReference/Chapters/EnablingLocalAndPushNotifications.html#//apple_ref/doc/uid/TP40011195-CH3-SW1

Can you try that to see if it will work for (1)?

@yoav-zibin not really.

Your first link is to PGB configuration documentation. According to it you can specify additional preferences for app configuration files in your project's config.xml. But it will only work for two of them, as stated in their docs:

platform: currently supported values are ios (Info.plist) and android (AndroidManifest.xml)

So, we can't use that for entitlements - iOS. Although, it can be used for Android.

About the second link - yes, you can add preferences to entitlements via plugin.xml config. But the problem is, that these preferences should be app-specific. To be able to add your own domains - you will have to:

  1. Fork this repo.
  2. Modify plugin.xml by adding app-specific preferences.
  3. In config.xml tell PGB to fetch plugin from your git url.

That should work, but it feels like a hack. That's why I said that 1 and 3 are the trickiest. But if someone wants to try out the plugin.xml approach - they can for iOS.

Let's say you had these preferences before in config.xml:

<universal-links>
  <host name="mywebsite.com">
    <path url="/first/path" event="first_event_name" />
    <path url="/second/path" event="second_event_name" />
  </host>
</universal-links>
  1. Fork this repo.
  2. In your new repo open plugin.xml and add the following:
<config-file target="*/Entitlements-Debug.plist" parent="com.apple.developer.associated-domains">
      <array>
        <string>applinks:mywebsite.com</string>
      </array>
</config-file>

<config-file target="*/Entitlements-Release.plist" parent="com.apple.developer.associated-domains">
      <array>
        <string>applinks:mywebsite.com</string>
      </array>
</config-file>
  1. In your project create www/ul.json file with the following content:
[{
    "host": "mywebsite.com",
    "path": [{
        "url": "/first/path",
        "event": "first_event_name"
    }, {
        "url": "/second/path", 
        "event": "second_event_name"
    }]
}]
  1. In your project's config.xml define link to the UL plugin:
<plugin spec="https://github.com/YOUR_ACCOUNT_NAME/cordova-universal-links-plugin.git" source="git" />
  1. Now the project should be configured and you can try it out.

I'm not sure you have to fork: you can pass parameters to the plugin, and then use them in plugin.xml like this:
<string name="google_app_id" translatable="false">$SENDER_ID</string>

The most common use case is just have a single universal link that you want to handle, e.g., for me it's https://friendlygo.com/
I think passing one parameter for your domain and using it in plugin.xml is an acceptable first step that will satisfy most users (no need to support all the plugin features on PGB :))

@yoav-zibin yes, but the problem is not in passing parameters to the plugin. The problem is that we need to add some preferences to the native config - .entitlements file. And these preferences tell native platform (iOS) that we are supporting Universal Links technology.

Right now for non-PGB projects this is handled by the plugin's JS hooks: when you build the project - they generate this .entitlements file and add it to the native project. But since we don't have hooks support - we need other ways to add preferences in there. And for now the only way I found to do that is with forking, because you can't inject preferences in .entitlements file via config.xml. At least I didn't find it in the documentation...

@nikDemyankov I have try the fork solution. Not yet working on android and ios.

On Android after pgb generate the apk file, I did not find some intent reference in the AndroidManifest.xml.
On IOS after pbg generate the ipa file, nothing in the info.plist. No folder ul_web_hooks / ios found...

Do I miss something?

@maktibab

On Android after pgb generate the apk file, I did not find some intent reference in the AndroidManifest.xml.

At the moment fork solution is only for iOS. Wanted to test it first.
Also, you should use Cordova iOS platform version 4.3 or above.

On IOS after pbg generate the ipa file, nothing in the info.plist.

It should not be in the info.plist. It should be in Entitlements-Debug.plist and Entitlements-Release.plist. But if these files are not allowed by the PGB - then we are screwed.

No folder ul_web_hooks / ios found...

That folder is generated by the plugin's JS hooks. And it's just for developer's convenience so he/she would not need to generate apple-app-site-association file manually. It is not bundled with the app but placed manually in the root of your site. If you already have this file on your site - good. If not - you can create it as described here or here.

@nikDemyankov

It should not be in the info.plist. It should be in Entitlements-Debug.plist and Entitlements-Release.plist. But if these files are not allowed by the PGB - then we are screwed.

Only info.plist found in the ipa file generated by PGB :(

@maktibab Okay, thanks for testing, I'll see what can be done.

@nikDemyankov some news about this issue?

@maktibab no, sorry, didn't have time to do anything lately... I'm really struggling right now with supporting plugins.

For those working on a stopgap or the permanent fix, there are going to be some obstacles for iOS. This is the most recent reference I can offer: https://forums.adobe.com/thread/2290461

๐Ÿ‘‹ Hi! Thank you for your interest in this repo.

๐Ÿ˜ข We are not using nordnet/cordova-universal-links-plugin anymore, and we lack the manpower and the experience needed to maintain it. We are aware of the inconveniece that this may cause you. Feel free to use it as is, or create your own fork.

๐Ÿ”’ This will now be closed & locked.

โ„น๏ธ Please see #160 for more information.