开发者

In-App purchase auto renew transaction restore problem

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.

  1. I have given a button titled "Already a Subscriber".开发者_JS百科 When user tap that I call following code.

    [[SKPaymentQueue defaultQueue] addTransactionObserver:self];
    [[SKPaymentQueue defaultQueue] restoreCompletedTransactions];           
    
  2. 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;
    
  3. 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.....


Within your class, you have to implement the callback function paymentQueue:updatedTransactions:

This function will receive updates on the transactions as and when it’s made. Because your transactions take place even when the app is closed, you should be ready to receive these notifications as soon as you open the app. So the best place is to initialize it in applicationDidFinishLaunching or equivalent method.

from this link

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜