I like the smell of Swift in the morning…

iOS9 In-App Purchase bug when user cancels the purchase process

Posted: | Author: | Filed under: iOS | Tags: , , | No Comments »

I just stumbled upon a bug that seems to be introduced in iOS9. When a user tries to buy a product via In-App Purchase and then cancels the process when he is asked if he really wants to buy the product a wrong error type is returned by Apple.

When the user presses “Cancel” in the UIAlertView the SKPaymentTransactionObserver method paymentQueue:updatedTransactions: gets called. The cancellation is handled like an error with the error type SKErrorPaymentCancelled. You can check for this error type because you don’t really want to show an error page when the user cancelled the purchase process. It’s not really an error but the user’s free will. So you only show an error message for the other error types:

- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions {
    for (SKPaymentTransaction *transaction in transactions) {
        switch (transaction.transactionState) {
            case SKPaymentTransactionStateFailed:
                if (transaction.error.code == SKErrorPaymentCancelled) {
                   // just cancel the purchase process without
                   // showing an error message
                } else {
                   // show an error message

So far, so good. Unfortunately under iOS9 when the user cancels the error type SKErrorUnknown is returned from Apple. That is unfortunate as it results in an error message being displayed when the user pressed “Cancel”. Somehow the correct error type SKErrorPaymentCancelled got lost in iOS9.

That is unfortunate, because we really don’t want to show the error message when the user cancels the purchase process. I do not see a solution for this problem as we cannot suppress all error messages of type SKErrorUnknown.

I filed a radar. Would be nice if Apple would fix that soon. Well, we know how seriously Apple treats radars, but hey, one can dream…

UPDATE: This is now fixed with the iOS9 release version

How to add a large amount of In-App Purchase items to iTunesConnect

Posted: | Author: | Filed under: iOS, Tools | Tags: , , | No Comments »

Adding In-App Purchase items to your Application in iTunesConnect by hand is a boring and time consuming task. When I realized that I’d have to add about 1000 items for my app I really did not want to do that manually. Luckily there is a tool for mass upload of In-App Purchase items. It is a bit hidden though.

When you log in to iTunesConnect and select “Manage your Apps” there is a section in the footer called Application Loader. That’s the tool you’ll need.

Download Application Loader and the Spreadsheet Example. With Application Loader you can select a text file that contains a list of the In-App Purchase items that you want to add to your app. It is a tab separated list that contains all the metadata that you’d normally add manually when adding an item in iTunesConnect. Have a look at the spreadsheet example to see what format the list should have.

To add the mandatory screenshots I found it easiest to put all the screenshots in one folder and name the screenshot according to the product ID. If your item’s product ID is com.yourdomain.product1 than the screenshot must be named com.yourdomain.product1.jpg.

If you have that text file all you have to do is select the file in Application Loader, select the screenshot folder, hit “next” a couple of times and then “deliver”.

Voilá, that’s it! Do not panic if your new In-App Purchase items do not show up in iTunesConnect right away. Sometimes it takes a couple of hours(!) before the show up.