[英]In App purchase for iOS (Appcelerator)
I want to add in-app purchase functionality for iOS but I can't make it working. 我想为iOS添加应用内购买功能,但无法正常运行。
I tried to use ti.storekit, but when I initialize it I get error that addTransactionObserver
is undefined and this is crucial function on initialization. 我尝试使用ti.storekit,但是在对其进行初始化时,我收到addTransactionObserver
错误消息,即addTransactionObserver
未定义,这对初始化至关重要。
Does anyone have luck with it? 有人有运气吗?
My code: 我的代码:
var storekit = require('ti.storekit');
var transactionStateChanged = function(e) {
alert(e)
}
function init() {
storekit.receiptVerificationSandbox = Ti.App.deployType !== 'production';
storekit.bundleVersion = '1.0.4';
storekit.bundleIdentifier = 'pl.aplikacjanowa';
storekit.addEventListener('transactionState', transactionStateChanged);
storekit.addTransactionObserver();
}
init();
Error: 错误:
[INFO] : [object TiStorekitModule] loaded
[ERROR] : Script Error {
[ERROR] : column = 37;
[ERROR] : line = 598;
[ERROR] : message = "undefined is not a function (evaluating 'storekit.addTransactionObserver()')";
[ERROR] : sourceURL = "file:///xyz"; //instead of xyz is path to file in which that function invoked
[ERROR] : stack = "init@file:///xyz"; //instead of xyz is path to file in which that function invoked
[ERROR] : }
It seems you initially used outdated version of the module or incorrectly compiled it. 看来您最初使用的是模块的过时版本或未正确编译。
As you mention in your comment something did go wrong with compiling I'm assuming that is the issue. 正如您在评论中提到的那样 ,编译确实出现了问题,我认为这就是问题所在。 A good description how to implement the module is on Medium , and releases are available for download from the Appcelerator GitHub . 在Medium上很好地描述了如何实现该模块,并且可以从Appcelerator GitHub下载版本。 Don't trust on Gitt.io from always having the latest. 不要一直拥有最新消息,不要相信Gitt.io。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.