2012-03-26 62 views
2

我試圖讓MKStoreKit與我的Cocos2D遊戲一起工作。它看起來非常簡單,我已經多次執行了所有步驟(檢查我是否正確完成),但仍然無法實現。我可以檢索產品名稱,價格和描述等,但我可以使用共享的MKStoreKitManager進行購買。MKStoreKit購買功能什麼都不做

這是我購買一個產品代碼:

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

回答

0

我不知道什麼是不工作的iPhone 4設備上,但消費人最完整的工作日試圖得到這個工作,我決定後,從頭開始一個新項目,然後重試。我做了一切都完全一樣,這一切工作!

+0

我現在正面臨這個問題.... – user216661 2013-01-26 19:09:14

+1

比浪費時間修復第三方解決方案更容易實現StoreKit.framework和相關協議SKPaymentTransactionObserver,SKProductsRequestDelegate,SKRequestDelegate。 .. – holex 2013-08-18 08:41:19

2

只要你的應用程序啓動,請致電:

[MKStoreManager sharedManager]; 

就是這樣。只要您在產品下載完成後調用-buyFeature:方法(如果需要,您可以觀察kProductFetchedNotification)一切都按預期工作。

+1

謝謝你。 MKStoreKit文檔留下了許多不足之處。這也修復了NSUbiquitousKeyValueStore錯誤,許多人似乎也越來越多。 – Brynjar 2013-03-13 15:39:19

0

確保您已將您的IAP密鑰添加到MKStoreKitConfigs.plist。沒有它,它什麼都不做。

此外,它可能需要幾個小時,直到一個註冊IAP變得可用於測試。

+0

Ehem,什麼是IAP密鑰,我如何將它插入MKStoreKitConfigs.plist? 謝謝。 – 2013-10-31 17:00:36