2015-07-19 57 views
1

在我的离子科尔多瓦应用程序,我使用的应用程序内购买插件:https://github.com/j3k0/cordova-plugin-purchase初始化的Android应用程序内结算使用科尔多瓦插件

这里是我用来初始化存储中的方法:

storekit.init({ 
      debug: true, // Enable IAP messages on the console 
      ready: service.IAP.onReady, 
      purchase: service.IAP.onPurchase, 
      restore: service.IAP.onRestore, 
      error: service.IAP.onError 
     }); 

这个初始化在iOS上运行良好,所有产品加载也很好,但Android设备不会加载购买。

我想,对于android有一个不同的初始化方法。

我已经在应用程序中添加插件:

cordova plugin add cc.fovea.cordova.purchase --variable BILLING_KEY="<BILLING_KEY>" 

请帮助。

回答

4

首先,当我使用它时,npm版本在android上是一个小bug。尝试删除它并从Git中添加它。其次,它看起来像你可能正在使用一些较老的语法。这个插件的doco并没有很好的版本控制。网络上有不同版本的doco。我认为this是最新版本。

这是我的初始化代码。看看它是否也适合你。

  products = ["my.test.product"]; 
      for (var i = 0; i < products.length; i++) { 
       if (window.store) { 
        store.register({ 
         id: products[i], 
         alias: 'alias '+i, 
         type: store.NON_CONSUMABLE 
        }); 

       } 
      } 

      // When everything goes as expected, it's time to celebrate! 
      if (window.store) store.ready(function() { 
       console.log("\\o/ STORE READY \\o/"); 
      }); 

      // After we've done our setup, we tell the store to do 
      // it's first refresh. Nothing will happen if we do not call store.refresh() 
      if (window.store) store.refresh(); 

您也可以将存储对象发送到console.log,以便在chrome调试器中查看它。

哦,如果您有多个应用程序,请通过删除并读取插件确保使用正确的BILLING_KEY。

祝你好运!

+0

非常感谢你:) – star18bit

相关问题