Two cordova plugins modifying "*-Info.plist" CFBundleURLTypes
Asked Answered
M

2

6

I have 2 cordova plugins that are modifying CFBundleURLTypes: The first one:

<config-file target="*-Info.plist" parent="CFBundleURLTypes">
  <array>
    <dict>
      <key>CFBundleURLSchemes</key>
      <array>
        <string>$URL_SCHEME</string>
      </array>
    </dict>
  </array>
</config-file>

The second one:

<config-file target="*-Info.plist" parent="CFBundleURLTypes">
  <array>
    <dict>
      <key>CFBundleURLSchemes</key>
      <array>
        <string>fb$APP_ID</string>
      </array>
     </dict>
  </array>
</config-file>

Only the first plugin that is added is modifying the "*-Info.plist".

Is there a way to make both plugins to be appending -Info.plist file?

Milieu answered 12/11, 2014 at 12:19 Comment(2)
I think you should open a feature request or an issue on the cordova JIRAAgle
Thanks, I've opened it: issues.apache.org/jira/browse/CB-8007Milieu
E
8

On Cordova 3.6.3-0.2.13, both configuration values are being added but in this manner:

<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>fb12345678</string>
        </array>
    </dict>
    <dict>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>anotherUrlScheme</string>
        </array>
    </dict>
</array>

On Cordova 4.0 and up (4.0.0, 4.1.2, 4.2.0), the second added plugin's configuration values will just get ignored. Thus, the plist will look like (Assuming facebook plugin get's added first):

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

As a workaround, we modified the facebook plugin to add two URL schemes, one from APP_ID (fb$APP_ID) and created another one for the URL SCHEME plugin. We checked-out facebook plugin source to be able to modify the source, and added the plugin from this directory instead of getting from GIT.

In phonegap-facebook-plugin's plugin.xml:

<config-file target="*-Info.plist" parent="CFBundleURLTypes">
    <array>
        <dict>
          <key>CFBundleURLSchemes</key>
          <array>
            <string>fb$APP_ID</string>
            <string>$URL_SCHEME</string>
          </array>
        </dict>
    </array>
</config-file>

On "plugin add" of facebook-plugin, provide the URL_SCHEME for the other plugin.

This way, it will add both URL schemes for both plugins when facebook plugin is being installed. I know it's really really hackish way to solve this issue, but we need to this feature ASAP and can't afford to wait for Cordova to add this feature.

Please let me know if you guys have another approach.

Elissaelita answered 7/1, 2015 at 11:7 Comment(2)
I will add this to my already long list of custom plugin modifications, thanks :)Ailis
Thanks for the workaround. Althought it does not solve the problem with other plugins, it is a good workaround.Milieu
L
0

I use this sentence to add "URL Types" to IOS PLATFORM on Apache Cordova:

<config-file target="*-Info.plist" parent="CFBundleURLTypes">
    <array>
        <dict>
            <key>CFBundleURLSchemes</key>
                <array>
                    <string>**APP_NAME**</string>
                </array>

            <key>CFBundleURLName</key>
            <string>**PACKAGE_ID**</string>
        </dict>
    </array>
</config-file>
Lucho answered 7/9, 2020 at 7:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.