iphone - MKStoreKit 购买功能不执行任何操作

标签 iphone objective-c in-app-purchase mkstorekit

我正在尝试让 MKStoreKit 与我的 Cocos2D 游戏一起使用。它看起来很简单,我已经按照所有步骤操作了几次(以检查我是否正确完成),但我仍然无法让它工作。我可以检索产品名称、价格和描述等。但我可以使用共享的 MKStoreKitManager 进行购买。

这是我购买产品的代码:

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 的 iPhone 4 设备上进行测试

最佳答案

您的应用启动后,立即调用:

[MKStoreManager sharedManager];

就是这样。只要您在下载产品后调用 -buyFeature: 方法(如果需要,您可以观察 kProductFetchedNotification),一切都会按预期进行。

关于iphone - MKStoreKit 购买功能不执行任何操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9880313/

相关文章:

iphone - 一个 View Controller 中的多个 UIActionSheet

iphone - 如何创建图像的 GridView ?单击图像时,它应该打开该图像

ios - 由于后台定位模式被拒绝

ios - 使用 ARC 弹出 View Controller 后内存未释放

android - 在 Google In-App Billing API 中使用什么作为开发人员有效负载?

iphone - 定期吊销证书的任何问题

iphone - 对图像使用@2X

objective-c - Clang: "Method returns an Objective-C object with a +0 retain count"想告诉我什么?

android - 应用内结算不适用于 G1

ios - 恢复应用内购买错误 : restores even if not purchased