ionic-team / ionic-plugin-deeplinks

Handle deeplinks into your Ionic/Cordova apps from Universal Links, App Links, and Custom URL schemes. For those using Ionic 2, there are some nice goodies that make life easier.
Other
332 stars 220 forks source link

[Android] - Config.xml Variable updates not supported #80

Open captaincole opened 7 years ago

captaincole commented 7 years ago

When I configured my plugin I have this specified.

  <plugin name="ionic-plugin-deeplinks" spec="~1.0.14">
    <variable name="URL_SCHEME" value="plank38"/>
    <variable name="DEEPLINK_SCHEME" value="https"/>
    <variable name="DEEPLINK_HOST" value="api.38plank.com"/>
    <variable name="ANDROID_PATH_PREFIX" value="/" />
  </plugin>

And the value that shows up in the AndroidManifest.xml is

            <intent-filter android:autoVerify="true">
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data android:host="38plank.com" android:pathPrefix="/" android:scheme="https" />
                <data android:host=" " android:pathPrefix="/" android:scheme=" " />
                <data android:host=" " android:pathPrefix="/" android:scheme=" " />
                <data android:host=" " android:pathPrefix="/" android:scheme=" " />
                <data android:host=" " android:pathPrefix="/" android:scheme=" " />
            </intent-filter>

where I would expect my android:host to equal "api.38plank.com"

captaincole commented 7 years ago

I have found the real issue here. This plugin does not update based on variables set in the config.xml file, only upon what was originally set in the installation call.

What I would expect is that when I save a new config.xml and rebuild my environment, the new configuration should show up in the new AndroidManifest.xml.

captaincole commented 7 years ago

After looking through your code, I have found what is happening. I guess this should be relabled as an "Enhancement" although it seems like something that should be supported out of the box.

in hooks/lib/afterPrepareHook.js you are succesfully retrieving the deepLinkHost variable from config.xml, but then do not write it out to the AndroidManifest.xml file. It seems that you do this for iOS though.

function activateUniversalLinksInIos(cordovaContext, deeplinkHost) {
    // modify xcode project preferences
    iosProjectPreferences.enableAssociativeDomainsCapability(cordovaContext);

    // generate entitlements file
    iosProjectEntitlements.generateAssociatedDomainsEntitlements(cordovaContext, deeplinkHost);
}

Would definitely make a pull request with fix, but I am not sure what the proper way to write out to the android.json file is.

Prabhat36 commented 7 years ago

im also facing this issue, can anyone help me @thielCole screenshot from 2017-02-21 16-52-00

captaincole commented 7 years ago

@Prabhat36 The workaround is to uninstall and reinstall the plugin with the correct variables.

jacquesdev commented 7 years ago

@thielCole - for interests sake, why did you specify these settings, or where did you see that the plugin depended on them?

<plugin name="ionic-plugin-deeplinks" spec="~1.0.14">
    <variable name="URL_SCHEME" value="plank38"/>
    <variable name="DEEPLINK_SCHEME" value="https"/>
    <variable name="DEEPLINK_HOST" value="api.38plank.com"/>
    <variable name="ANDROID_PATH_PREFIX" value="/" />
</plugin>

I am asking because it was not specified in the docs anywhere, so just wanted to confirm if this is necessary?

jacquesdev commented 7 years ago

@Prabhat36 - I guess you are having the same issue as I logged here https://github.com/driftyco/ionic-plugin-deeplinks/issues/81.

Prabhat36 commented 7 years ago

https://github.com/nordnet/cordova-universal-links-plugin @jacquesdev use this plugin it works like charm and well explained plugin

jacquesdev commented 7 years ago

Thanks @Prabhat36 - that is an excellent suggestion!

captaincole commented 7 years ago

Yes, I used this plugin because it was hosted by ionic. @jacquesdev to answer your question, I did it by adding a --save at the end of my plugin install command

cordova plugin add ionic-plugin-deeplinks@1.0.14 --variable URL_SCHEME='MyScheme' --variable DEEPLINK_SCHEME=https --variable DEEPLINK_HOST=MyURL.com --save

@Prabhat36 I only used this because it was hosted by ionic and I am developing on top of that framework, but the other plugin looks very good also.