下次启动时无法成功完成应用内购买交易
对于由于中断(来电等)而未完成的交易,当我重新启动应用程序时,我会收到更新,因为我正在向支付队列添加观察者。但我如何知道哪笔交易正在通过网络发送。我尝试过这
for (SKPaymentTransaction *transaction in transactions)
{
switch (transaction.transactionState)
{
case SKPaymentTransactionStatePurchasing:
//Show a loading View
NSLog(@"Purchase Ongoing");
break;
case SKPaymentTransactionStatePurchased:
[self completeTransaction:transaction];
break;
}
}
-(void) completeTransaction:(SKPaymentTransaction *) transaction
{
NSString *productIdentifier = transaction.originalTransaction.payment.productIdentifier;
NSLog (productIdentifier);
//this line doesn't log anything. I run it in debug mode and I see productIdentifier as InvalidCFString (0x0). I guess it's nill.
}
是因为在我的应用程序被杀死之前我无法正确完成交易。杀掉后,我确实从 Apple 收到了您的应用内购买成功的消息。只是我无法在我的应用程序被杀死之前完成交易。当时该交易正在进行中。尝试在应用程序被杀死之前强制完成交易会导致应用程序崩溃,并显示“无法完成正在进行的交易”,因为我尚未收到 SKPaymentTransactionStatePurchased 通知。
现在,当我重新启动时,我收到了一些响应,但我无法读取它并解锁我必须的功能,因为金额已记入用户的 itunes 帐户。如何解决这个问题?
提前致谢。
For my unfinished transactions due to interruptions(incoming call etc.), I am getting updates when I relaunch the application as I am adding an observer to the payment queue. But how do I know which is the transaction that's being sent down the wire. I have tried this
for (SKPaymentTransaction *transaction in transactions)
{
switch (transaction.transactionState)
{
case SKPaymentTransactionStatePurchasing:
//Show a loading View
NSLog(@"Purchase Ongoing");
break;
case SKPaymentTransactionStatePurchased:
[self completeTransaction:transaction];
break;
}
}
-(void) completeTransaction:(SKPaymentTransaction *) transaction
{
NSString *productIdentifier = transaction.originalTransaction.payment.productIdentifier;
NSLog (productIdentifier);
//this line doesn't log anything. I run it in debug mode and I see productIdentifier as InvalidCFString (0x0). I guess it's nill.
}
Is this because I couldn't finish the transaction properly before my app got killed. After killing, I do get the message that your In-App purchase was successful from Apple. It's just that I couldn't finish the transaction before my app got killed. The transaction was ongoing at that time. Trying to force finish the transaction before the app getting killed crashes the application saying "Can't finish an ongoing transaction" as I had not yet received the SKPaymentTransactionStatePurchased notification.
Now when I relaunch, I get some response but I am not able to read it and unlock the functionality which I must as the amount has already been debited to the user's itunes account. How to tackle this?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论