2

我正在尝试让 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 设备上进行测试

4

3 回答 3

2

一旦您的应用程序启动,请致电:

[MKStoreManager sharedManager];

而已。只要您在下载产品后调用-buyFeature:方法(如果需要,您可以观察kProductFetchedNotification),一切都会按预期工作。

于 2013-03-02T10:10:01.017 回答
0

我不知道什么不工作,但在花了几乎一整天的时间试图让它工作后,我决定从头开始一个新项目,然后再试一次。我所做的一切都完全相同,而且一切正常!

于 2012-03-27T13:22:41.083 回答
0

确保将 IAP 密钥添加到MKStoreKitConfigs.plist。没有它,它什么也做不了。

此外,注册 IAP 可能需要几个小时才能进行测试。

于 2013-08-18T04:55:38.890 回答