Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone MKStoreKit购买功能不起任何作用_Iphone_Objective C_In App Purchase_Mkstorekit - Fatal编程技术网

Iphone MKStoreKit购买功能不起任何作用

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"); }

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

我不知道什么不起作用,但在花了几乎一整天的时间试图让它起作用后,我决定从头开始一个新项目,然后再试一次。我做的每件事都一模一样,一切都成功了

应用程序启动后,立即拨打:

[MKStoreManager sharedManager];

就这样。只要在产品下载后调用-buyFeature:方法(如果愿意,您可以观察kProductFetchedNotification),一切都会正常工作。

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


另外,可能需要几个小时,注册IAP才能用于测试。

谢谢。MKStoreKit文档还有很多需要改进的地方。这还修复了许多人似乎也会遇到的NSUbiquitousKeyValueStore错误。与浪费时间修复第三部分解决方案相比,更容易实现
StoreKit.framework
和相关协议
SKPaymentTransactionObserver
SKProductsRequestDelegate
SKRequestDelegate
,IAP密钥是什么?如何将其插入mkstorekitconfigums.plist?谢谢