使用cordova插件初始化Android In App Billing [英] Initialization Android In App Billing using cordova plugin

查看:522
本文介绍了使用cordova插件初始化Android In App Billing的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的离子Cordova应用程序中,我使用In App Purchase Plugin: https:// github。 com / j3k0 / cordova-plugin-purchase

In My ionic Cordova Application, I am using In App Purchase Plugin: https://github.com/j3k0/cordova-plugin-purchase

以下是我用来初始化商店的方法:

Here is the method that I use to initialise store:

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设备无法加载在购买。

This Initialization works fine with iOS and all the products loading fine as well, But Android device does not load In Purchase.

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

I guess, For android there is a different initialization method.

我添加了插件app:

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

请帮忙。

推荐答案

首先,当我使用它时,npm版本在android上有点小错误。尝试删除它并从Git添加它。

Firstly, when I was using it, the npm version was a little buggy on android. Try removing it and adding it from Git.

cordova plugin add https://github.com/j3k0/cordova-plugin-purchase.git --variable BILLING_KEY="MIIB...AQAB"

其次,它看起来像你可能正在使用一些较旧的语法。这个插件的doco真的没有很好的版本控制。整个网络都有不同版本的doco。我认为这个是最新版本。

Secondly, it looks like you are maybe using some older syntax. The doco for this plugin doesnt really have very good version control. There are different versions of doco all over the net. I think this is the latest version.

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

This is my initialisation code. See if it works for you too.

            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调试器中仔细查看它。

You can also send the store object to console.log to have a good look at it in chrome debugger.

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

Oh, and if you have more than one app, make sure you are using the correct BILLING_KEY by removing and readding the plugin.

祝你好运!

这篇关于使用cordova插件初始化Android In App Billing的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆