Reputation: 549
I'm trying to get the MKStoreKit working with my Cocos2D game. It look pretty simple to do and I've followed all the steps a couple of times (to check I've done it correctly) but I still can't get it to work. I can retrieve a product name, price and description etc. but I can use the shared MKStoreKitManager to make a purchase.
Here's my code for buying a product:
if([MKStoreManager isFeaturePurchased: @"com.testing.iap.removeAds"]) {
NSLog(@"No ads");
}else{
NSLog(@"Ads");
NSLog(@"Buying feature...");
[[MKStoreManager sharedManager] buyFeature: @"com.testing.iap.removeAds"
onComplete:^(NSString* purchasedFeature)
{
NSLog(@"Purchased: %@", purchasedFeature);
// provide your product to the user here.
// if it's a subscription, allow user to use now.
// remembering this purchase is taken care of by MKStoreKit.
}
onCancelled:^
{
NSLog(@"Something went wrong");
// User cancels the transaction, you can log this using any analytics software like Flurry.
}];
}
Basically if the product hasn't been previously purchased, kick off the purchase process. The problem is nothing happens! I don't even get the onCancelled being called and there are no error messages apart from the one's I can ignore (i.e. iCloud support and custom server options).
Can anyone shed some light on what it is thats stopping me?
Note: I'm testing on an iPhone 4 device running iOS 5.1
Upvotes: 2
Views: 1392
Reputation: 21571
Make sure you added your IAP key to the MKStoreKitConfigs.plist. Without that it does nothing.
Also it can take a few hours until a register IAP becomes available for testing.
Upvotes: 0
Reputation: 790
As soon as your app launches, call:
[MKStoreManager sharedManager];
That's it. As long as you call the -buyFeature: method after the products have been downloaded (you could observe kProductFetchedNotification if you want) everything works as expected.
Upvotes: 2
Reputation: 549
I have no idea what wasn't working but after spending al most a full working day trying to get this to work I decided to start a new project from scratch and try again. I done everything exactly the same and it all worked!
Upvotes: 0