在SKPaymentTransactionState
告訴SKPaymentTransactionStateFailed
之前,你的請求添加到服務器隊列。
@class SKPayment;
enum {
SKPaymentTransactionStatePurchasing, // Transaction is being added to the server queue.
SKPaymentTransactionStatePurchased, // Transaction is in queue, user has been charged. Client should complete the transaction.
SKPaymentTransactionStateFailed, // Transaction was cancelled or failed before being added to the server queue.
SKPaymentTransactionStateRestored // Transaction was restored from user's purchase history. Client should complete the transaction.
};
typedef NSInteger SKPaymentTransactionState;
而且在SKPaymentTransaction
類參考錯誤討論說:
error屬性未定義時transactionState設置爲SKPaymentTransactionStateFailed
除外。您的應用程序可以讀取錯誤屬性以確定事務失敗的原因。
所以,transaction.error.localizedDescription是 「無法連接到iTunes Store的」!是一般錯誤消息。我在測試InApp購買時也定期收到此錯誤消息。
一些提示ü可以做的是,
使用SKProductsRequest
檢索應用程序商店的所有產品,並檢查其response.products
包含您的要求productIdentifier
。 用於該用途,
SKProductsRequest *request = [[SKProductsRequest alloc] initWithProductIdentifiers:[NSSet setWithArray:[objProducts allKeys]]];
//pass product identifier array as argument
[request start];
,趕上應答:
- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response{
NSArray *myProduct = response.products;
}
所以,你可以決定你是可以對應用程序商店通信。和你的產品ID在那裏。
- 確保您使用在應用測試用戶帳戶進行測試。
- 而且您使用的是您在應用程序購買中配置的相同應用程序ID設置。
感謝
你有沒有找到解決問題的方法?最近我遇到了這個問題,在沙盒服務器關閉之前,該商店在我的iPad上工作。它再次上線後,它不再工作。我將iPad項目中使用的相同代碼複製到iPhone項目項目中,並使用兩種不同的iPhone進行測試,然後運行。但它似乎不再適用於iPad應用程序。怎麼了? – NicTesla 2011-07-21 08:32:43
使用StoreKit時,「無法連接到iTunes Store」錯誤消息似乎是用於各種不同網絡相關錯誤代碼的通用消息。特定的代碼-1003是'CFNetworkErrors.h'中定義的'kCFURLErrorCannotFindHost'。 – markshep 2011-09-13 14:31:59
我有同樣的問題,但不幸的是第二次機會確認購買, 任何想法??? – 2012-11-20 11:54:08