用作者自己的话说:It took several days of blood, sweat, and tears to get it working in my own application, and hopefully this post has helped short circuit that cycle of pain and suffering for you as well.
另外在failedTransaction中添加如下代码输出失败原因,当然它可能很不靠谱,总是给你一个0号错误,描述为Error Domain=SKErrorDomain Code=0 "无法连接 iTunes Store", switch (transaction.error.code) { case SKErrorUnknown: NSLog(@"SKErrorUnknown"); break; case SKErrorClientInvalid: NSLog(@"SKErrorClientInvalid"); break; case SKErrorPaymentCancelled: NSLog(@"SKErrorPaymentCancelled"); break; case SKErrorPaymentInvalid: NSLog(@"SKErrorPaymentInvalid"); break; case SKErrorPaymentNotAllowed: NSLog(@"SKErrorPaymentNotAllowed"); break; default: NSLog(@"No Match Found for error"); break; } NSLog(@"transaction.error.code %@",[transaction.error description]);