ios - 修改 "*-Info.plist"CFBundleURLTypes 的两个 cordova 插件

标签 ios cordova cordova-plugins

我有 2 个正在修改 CFBundleURLTypes 的 cordova 插件: 第一个:

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

第二个:

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

只有添加的第一个插件正在修改“*-Info.plist”。

有没有办法让这两个插件都附加 -Info.plist 文件?

最佳答案

在 Cordova 3.6.3-0.2.13 上,两个配置值都以这种方式添加:

<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>

在 Cordova 4.0 及更高版本(4.0.0、4.1.2、4.2.0)上,第二个添加的插件的配置值将被忽略。因此,plist 看起来像(假设首先添加了 facebook 插件):

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

作为解决方法,我们修改了 facebook 插件以添加两个 URL 方案,一个来自 APP_ID (fb$APP_ID) 并为 URL SCHEME 插件创建了另一个。我们检查了 facebook 插件源以便能够修改源,并从此目录添加插​​件而不是从 GIT 获取。

在 phonegap-facebook-plugin 的 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>

在 facebook-plugin 的“插件添加”中,为其他插件提供 URL_SCHEME。

这样,它会在安装 facebook 插件时为两个插件添加两个 URL 方案。我知道解决这个问题的方法真的很骇人听闻,但我们需要尽快使用此功能,不能等待 Cordova 添加此功能。

如果你们有其他方法,请告诉我。

关于ios - 修改 "*-Info.plist"CFBundleURLTypes 的两个 cordova 插件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26886891/

相关文章:

ios - Instagram 错误 "You can not like this media"?

ios - 为什么 iOS Container 不再取代 work?

javascript - 键盘消除后退按钮事件 - Android

javascript - 无法解析我的 Phonegap 项目中的 JSON 字符串错误

android - ionic 2 中的 window.resolveLocalFilesystemUrl

android - Cordova SSL 固定错误 500 : "There was an error with the request"

ios - 点击空的 UITableView 退出搜索栏

objective-c - 如何在 UINavigationController 的 bar 上方添加 UIImageView

jquery - knockout : Bind data object with select element's option

android - 向混合应用程序添加 native 功能