2

Sorry for that millionth question on autorenewable subscriptions, but i don't get it. I've done everything as describet in Apples In-App Purchase Guidelines but it didn't solve the problem.

My problem is that i have created autorenewable subscriptions but they won't be autorenewed.

I've create a Payment Transaction Observer class, which implements the SKPaymentTransactionObserver interface. This class will be installed as a paymentObserver at Application startup in the viewDidLoad: method.

PaymentTransactionObserver *observer = [[PaymentTransactionObserver alloc] init];

[[SKPaymentQueue defaultQueue] addTransactionObserver:observer];

In the paymenttransactionobserver i have the paymentQueue:updateTransactions method: (same as describet in Apple's documentation)

  • (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions { for (SKPaymentTransaction *transaction in transactions) {
    switch (transaction.transactionState) {

        case SKPaymentTransactionStatePurchased: 

            [self completeTransaction:transaction]; 

            break;

        case SKPaymentTransactionStateFailed: 

            [self failedTransaction:transaction]; 

            break;

        case SKPaymentTransactionStateRestored:

            [self restoreTransaction:transaction]; 

            break;

        default:

            break;
    }
}

When i buy a autorenewable product, the product will successfully be purchase. But it will never be autorenewed. I thought of, that the transaction observer, somehow will get deallocated, but it won't (Otherwhise, i would be notified by the debugger). I also though, i did remove the observer but it will never be removed.

I used the debugger to ensure, that the updateTranscations: method will get called, but nothing. When i buy a test product (in sandbox-mode) with autorenewal time of one week, the method should get called after 3 minutes, but it wont.

What am i doing wrong?

Can anybody help?

Br Nic

NicTesla
  • 1,626
  • 5
  • 21
  • 35

2 Answers2

1

If a subscription is autorenewed, the transaction won't pass the paymentQueue:updateTransactions method. The renew just happens on the Store. If you want to test for it you have to either:

  • Revalidate the receipt on your application server, if you store the receipt there.

  • Revalidate the receipt on ur iOS client

(http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/StoreKitGuide/VerifyingStoreReceipts/VerifyingStoreReceipts.html#//apple_ref/doc/uid/TP40008267-CH104-SW1)

In order to avoid testing for an autorenew each launch/activation you should store the endDate of the subscription period to test for a renew afterwards.

Also see:

http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/StoreKitGuide/RenewableSubscriptions/RenewableSubscriptions.html#//apple_ref/doc/uid/TP40008267-CH4-SW4

However, there seems to be a bug in the sandbox. Subscriptions sometimes get renewed, sometimes not. Hard to test....

Rene Berlin
  • 1,171
  • 7
  • 21
  • In the Sandbox they just get renewed six times for each test user, and then they stop, so you have to register a new test user for that – Nikita Pestrov Apr 03 '12 at 04:33
0

Auto-renewals only get posted to your app's purchase queue on app launch or when it cycles back from being backgrounded. Try clicking the home button and then returning to your app.

jemmons
  • 18,605
  • 8
  • 55
  • 84
  • But shouldn' it also work while the App is running? (Ok, you normally won't let your app run until the subscription has been expired, but from the developer site it would a normal thing and helpful aswell). Is it somewhere documented in apples purchase guidelines? I'll try this, but thanks for your response! – NicTesla Oct 05 '11 at 07:11
  • Do you call [[SKPaymentQueue defaultQueue] restoreCompletedTransactions]; on startup? – NicTesla Oct 05 '11 at 07:19
  • @NicTesla No. It should't also work while the app is running. That's why I said it doesn't work that way :) Check out 2011 WWDC video #510 at the 47:10 mark. – jemmons Oct 05 '11 at 19:44
  • @NicTesla And you should never call `restoreCompletedTransactions` on startup or in response to anything that is not direct user interaction. It pops up an alert asking for their Apple ID credentials and would be very confusing/annoying if it happened all the time/randomly. – jemmons Oct 05 '11 at 19:46
  • Ok, thx for providing this information! Anyhow, it still doesn't work, so i contacted an Apple Developer and they said that there is a bug in the sandbox mode in several stores. What store are you using? – NicTesla Oct 10 '11 at 08:58