2012-07-18 51 views
2

因此,基本上,我想在某些網絡/ iTunes特定原因恢復完成事務失敗時顯示警報,但當用戶點擊「取消」時,而不是 Apple ID /密碼提示。restoreCompletedTransactionsFailedWithError:錯誤代碼0(SKErrorUnknown)取消

我在執行的:

- (void)paymentQueue:(SKPaymentQueue *)queue restoreCompletedTransactionsFailedWithError:(NSError *)error 

...我測試error.codeSKErrorPaymentCancelled(也許我也應該測試對SKErrorPaymentNotAllowed,但現在這是不相關)。

儘管如此,攻時「取消」警報反正顯示。 NS-Logging其值顯示error.code == 0(即,SKErrorUnknown)。

這是發生在iOS 4.3.1時,Xcode 4.2,打造4C199(沙店,當然)。

我已經檢查了類似的問題,但什麼是回答沒有什麼是我的情況下發生的(即有什麼我已經在做應該得到正確的行爲)...任何想法?

回答

3

檢查這些。應該夠了。

// error codes for the SKErrorDomain 
enum { 
    SKErrorUnknown, 
    SKErrorClientInvalid,  // client is not allowed to issue the request, etc. 
    SKErrorPaymentCancelled, // user cancelled the request, etc. 
    SKErrorPaymentInvalid,  // purchase identifier was invalid, etc. 
    SKErrorPaymentNotAllowed // this device is not allowed to make the payment 
}; 

https://stackoverflow.com/a/9017990/129202

所以,我做的是我做的一個交換機上的error.code,只顯示一個錯誤時,不SKErrorPaymentCancelled代碼。用戶可能知道他/她推動了取消按鈕(當進入用戶/通行證時)。

所以SKErrorPaymentCancelled應該抓住取消。如果取消按鈕引發另一個錯誤代碼,那麼這個iOS版本有問題嗎?

2

我發現,在iOS模擬器,取消失敗,錯誤代碼0(SKErrorUnknown)。但是,如果您在設備上運行它,它會正確返回SKErrorPaymentCancelled。這似乎也適用於iOS 9。

相關問題