Two cordova plugins modifying “*-Info.plist” CFBundleURLTypes

依然范特西╮ 提交于 2019-12-03 16:27:18

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!