Iphone MKStoreKit购买功能不起任何作用
我正在尝试让MKStoreKit与我的Cocos2D游戏配合使用。这看起来很简单,我已经按照所有步骤做了好几次(以检查我是否正确地做了),但我仍然无法让它工作。我可以检索产品名称、价格和说明等,但我可以使用共享的MKStoreKitManager进行购买 以下是我购买产品的代码:Iphone MKStoreKit购买功能不起任何作用,iphone,objective-c,in-app-purchase,mkstorekit,Iphone,Objective C,In App Purchase,Mkstorekit,我正在尝试让MKStoreKit与我的Cocos2D游戏配合使用。这看起来很简单,我已经按照所有步骤做了好几次(以检查我是否正确地做了),但我仍然无法让它工作。我可以检索产品名称、价格和说明等,但我可以使用共享的MKStoreKitManager进行购买 以下是我购买产品的代码: if([MKStoreManager isFeaturePurchased: @"com.testing.iap.removeAds"]) { NSLog(@"No ads"); }
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.
}];
}
基本上,如果之前没有购买过该产品,则启动购买流程。问题是什么都没发生!我甚至没有调用onCancelled,除了我可以忽略的错误消息(即iCloud支持和自定义服务器选项)之外,没有其他错误消息
谁能解释一下是什么阻止了我
注意:我正在运行iOS 5.1的iPhone4设备上进行测试我不知道什么不起作用,但在花了几乎一整天的时间试图让它起作用后,我决定从头开始一个新项目,然后再试一次。我做的每件事都一模一样,一切都成功了 应用程序启动后,立即拨打:
[MKStoreManager sharedManager];
就这样。只要在产品下载后调用-buyFeature:方法(如果愿意,您可以观察kProductFetchedNotification),一切都会正常工作。确保已将IAP密钥添加到MKStoreKitConfigs.plist。没有这些,它什么也做不了
另外,可能需要几个小时,注册IAP才能用于测试。谢谢。MKStoreKit文档还有很多需要改进的地方。这还修复了许多人似乎也会遇到的NSUbiquitousKeyValueStore错误。与浪费时间修复第三部分解决方案相比,更容易实现
StoreKit.framework
和相关协议SKPaymentTransactionObserver
,SKProductsRequestDelegate
,SKRequestDelegate
,IAP密钥是什么?如何将其插入mkstorekitconfigums.plist?谢谢