Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Two cordova plugins modifying "*-Info.plist" CFBundleURLTypes

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?

like image 533
Miquel Avatar asked Nov 12 '14 12:11

Miquel


1 Answers

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.

like image 112
severedsea Avatar answered Oct 22 '22 14:10

severedsea