StoreKit Module crashing constantly
Is anyone else experiencing constant crashing from the StoreKit Module? I am getting "SKProductsRequest handleFinishResponse:returningError" in the crash logs.
The issue is intermittent. Sometimes I get a valid product array (so I know my app, products, and provisioning profile are all setup correctly), other times it just crashes right after the app opens. It seems like a timing issue.
To duplicate the issue, you can use the following code (you will need a valid app id with app store products and the corresponding provisioning profile).
My environment is as follows: iPhone 4, iOS SDK 4.3, Titanium Studio 1.0.4, Mobile SDK 1.7.2, Mac OS X 10.6.8, Apple StoreKit Module 1.1
Here is my crash log: https://gist.github.com/1171984
add this to tiapp.xml:
<modules>
<module version="1.1">ti.storekit</module>
</modules>
app.js
// this sets the background color of the master UIView (when there are no windows/tab groups on it)
Titanium.UI.setBackgroundColor('#000');
// In-App purchases
Titanium.Storekit = Ti.Storekit = require('ti.storekit');
var storeProducts = [];
function createWindow (_args) {
var win = Ti.UI.createWindow(_args);
return win;
}
var win1 = createWindow({title:'Window 1'});
var tab1 = Titanium.UI.createTab({
title:'Tab 1',
window:win1
});
var win2 = createWindow({title:'Window 2'});
var tab2 = Titanium.UI.createTab({
title:'Tab 2',
window:win2
});
var tabgroup = Titanium.UI.createTabGroup();
tabgroup.addTab(tab1);
tabgroup.addTab(tab2);
tabgroup.open();
getStoreProducts = function(_args) {
if (_args===undefined) {_args={};};
storeProducts = []; // reset products array
if (!Ti.Storekit.canMakePayments) {
Ti.API.info("Can NOT make payments to in-app purchase store");
if (_args.error) {
_args.error({error:"Cannot make payments to in-app purchase store"});
};
Ti.UI.createAlertDialog({
title:'Error',
message:'Cannot make payments to in-app purchase store'
}).show();
} else {
try {
Ti.Storekit.requestProducts(['com.example.myapp.testProduct01'], function(e) {
if (!e.success) {
Ti.API.info("Could not get products: " + JSON.stringify(e));
if (_args.error) {
_args.error(e);
};
} else {
storeProducts = e.products;
Ti.App.fireEvent('app:store.hasProducts');
if (_args.success) {
_args.success(e);
};
}
});
} catch (e) {
Ti.API.info("Ti.Storekit.requestProducts EXCEPTION: " + JSON.stringify(e));
}
} // END if (!Ti.Storekit.canMakePayments)
};
win1.addEventListener('focus', function(e) {
Ti.API.info("Getting store products...");
getStoreProducts({
error: function(e) {
Ti.API.info("getStoreProducts ERROR: " + JSON.stringify(e));
},
success: function(json) {
Ti.API.info("getStoreProducts SUCCESS: " + JSON.stringify(json));
}
});
Ti.API.info("Simulating some data processing...");
setTimeout(function() {
Ti.API.info("DONE loading data...");
}, 8000);
});
win2.addEventListener('focus', function(e) {
Ti.API.info("Getting store products...");
getStoreProducts({
error: function(e) {
Ti.API.info("getStoreProducts ERROR: " + JSON.stringify(e));
},
success: function(json) {
Ti.API.info("getStoreProducts SUCCESS: " + JSON.stringify(json));
}
});
Ti.API.info("Simulating some data processing...");
setTimeout(function() {
Ti.API.info("DONE loading data...");
}, 8000);
});