我正在尝试通过 Phonegap build 使用 Apple Pay cordova 插件。这是我在配置文件中的条目:

     <plugin name="cordova-plugin-applepay-stripe" source="npm"> 
<param name="STRIPE_TEST_PUBLISHABLE_KEY" value="xxxxxxxx" /> 
<param name="STRIPE_LIVE_PUBLISHABLE_KEY" value="xxxxxxxxx" /> 
<param name="APPLE_MERCHANT_IDENTIFIER" value="merchant.etc.etc" /> 
</plugin> 

该插件可以正确安装,但它不会工作,因为我在使用 PC 时没有在 Xcode 中启用 Apply Pay 权利。

我知道您可以直接从 phonegap build config.xml 文件编辑 plist 文件,就像我在这里所做的那样:

<gap:config-file platform="ios" parent="NSPhotoLibraryUsageDescription" overwrite="true"> 
<string>We are using the Photo Library for PayPal</string>... 

所以我的问题是我到底应该如何编辑 Entitlements.plist 文件才能启用 ApplePay 并添加我的商家 ID?!

我尝试了以下方法:

  <config-file platform="ios" target="*-Entitlements.plist" parent="com.apple.developer.in-app-payments">   
        <array> 
            <string>merchant.etc.etc/string> 
        </array> 
</config-file>   

但这并没有奏效。任何帮助,将不胜感激!

请您参考如下方法:

由于某些原因,config-file 似乎只能在插件中使用。它似乎应该在您的项目 config.xml 中工作,但不幸的是它没有。但是,您可以使用本地插件来管理您的权利,以达到或多或少相同的效果。

例如,src/local-plugins/app-entitlements

将此添加到您的 config.xml

<plugin name="app-entitlements" spec="src/local-plugins/app-entitlements" /> 

您只需要 src/local-plugins/app-entitlements/plugin.xml 文件:

<?xml version="1.0" encoding="UTF-8"?> 
<plugin id="app-entitlements" version="0.0.0" xmlns="http://apache.org/cordova/ns/plugins/1.0"> 
  <name>AppEntitlements</name> 
  <platform name="ios"> 
    <config-file target="*-Debug.plist" parent="com.apple.developer.in-app-payments"> 
      <array> 
        <string>YOUR DEBUG MERCHANT ID HERE</string> 
      </array> 
    </config-file> 
    <config-file target="*-Release.plist" parent="com.apple.developer.in-app-payments"> 
      <array> 
        <string>YOUR RELEASE MERCHANT ID HERE</string> 
      </array> 
    </config-file> 
  </platform> 
</plugin> 

您当然可以在这里设置其他权利,例如推送通知或您想要的任何内容。

现在,当您执行全新的 cordova platform add ios 时,它应该使用这些 key 创建 Entitlements-*.plist,您应该可以开始了。

请记住,Xcode 中的“Capabilities”选项卡是单独处理的,它只是一个 GUI 助手。它不会反射(reflect)这些文件的权利。


评论关闭
IT序号网

微信公众号号:IT虾米 (左侧二维码扫一扫)欢迎添加!