应用内购买自动续费交易恢复问题
我正在开发一个应用程序,用户可以在其中购买自动续订订阅。购买部分工作正常,但当用户删除应用程序并尝试恢复其购买时会出现问题。以下是我为处理该问题而编写的代码。
我已经给出了一个标题为“已经是订阅者”的按钮。当用户点击时,我调用以下代码。
[[SKPaymentQueue defaultQueue] addTransactionObserver:self]; [[SKPaymentQueuedefaultQueue]restoreCompletedTransactions];
这就是我在
- (void) paymentQueue:(SKPaymentQueue *)queue UpdatedTransactions:(NSArray *)transactions
方法中处理恢复的方式。案例 SKPaymentTransactionStateRestored: 持续时间 = [strDuration intValue]; if(transaction.transactionReceipt != nil){ 收据 = [[NSString alloc] initWithData:[b64 dataByBase64EncodeFromData:transaction.transactionReceipt] 编码:NSASCIIStringEncoding]; [userDefault setObject:transaction.transactionReceipt forKey:@"LastReceipt"]; [队列完成事务:事务]; [自调用ReceiptInfoImpl]; } 休息;
以下是恢复事务完成时的委托方法。
-(void) paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)队列{ NSLog(@"已完成的事务已恢复"); }
是,当用户单击“已经是订阅者”按钮时,步骤 1. 会被调用,但步骤 2. 永远不会被调用。最后我可以在屏幕上看到消息“已完成交易已恢复”。
如果有人遇到类似的问题,请指导。
感谢您的阅读......
I am developing an application in which user can purchase auto-renewable subscription. Buying part is woking alright but problem occurs when user deletes the application and tries to restore his purchases. following is the code I wrote to handle that.
I have given a button titled "Already a Subscriber". When user tap that I call following code.
[[SKPaymentQueue defaultQueue] addTransactionObserver:self]; [[SKPaymentQueue defaultQueue] restoreCompletedTransactions];
And this is how I handle restore in
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
method.case SKPaymentTransactionStateRestored: duration = [strDuration intValue]; if(transaction.transactionReceipt != nil){ receipt = [[NSString alloc] initWithData:[b64 dataByBase64EncodeFromData:transaction.transactionReceipt] encoding:NSASCIIStringEncoding]; [userDefault setObject:transaction.transactionReceipt forKey:@"LastReceipt"]; [queue finishTransaction:transaction]; [self callReceiptInfoImpl]; } break;
Following is delegate method when restore transaction is completed.
-(void)paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue{
NSLog(@"COMPLETED TRANSACTION RESTORED");
}
Problem is that, when user clicks button "Already a subscriber" then Step 1. gets called but Step 2. never gets called. Finally I can see message "COMPLETED TRANSACTION RESTORED" on screen.
If anybody has faced similar problem then please guide.
Thanks for reading.....
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
来自此链接
from this link