Clearing purchases from iOS in-app purchase sandbox for a test user

前端 未结 8 884
臣服心动
臣服心动 2020-12-02 07:18

Does anyone have any ideas on how to reset and/or clear the iOS in-app purchase sandbox?

I have an app that I\'m testing with the sandbox, and I\'d like to test new

相关标签:
8条回答
  • 2020-12-02 08:11

    Just keep using the same test account, restoring purchases as opposed to completing new ones. After all, whether you start a new purchase or restore an old one, YOUR APP will do the same thing (at least initially, maybe the user interface will update differently upon completion). Apple are the folks handling things differently in those different situations - don't worry about it.

    Place your delivery logic in the SKPaymentTransactionStateRestored case within this method's implementation for testing:

    - (void)paymentQueue:(SKPaymentQueue *)queue
     updatedTransactions:(NSArray *)transactions;
    

    Then be sure to put that delivery logic into the SKPaymentTransactionStatePurchased case.

    At the end, because most of us are obsessive-compulsive to varying degrees, do a final test with a fresh account (not a big deal to make a second one for absolute certainty).

    The final thing to note: consider apple's position. If there was a problem with developers having to waste time creating tens or hundreds of accounts to test IAP thoroughly, they would have solved the problem. There is no problem.

    0 讨论(0)
  • 2020-12-02 08:13

    IMO there are 3 things you can do to make testing non-consumables bearable:

    1. You can have many test accounts associated to one email. Gmail for example lets you add a "plus" string to the email to create aliases for an address: so tester+01@gmail.com and tester+02@gmail.com both really just go to tester@gmail.com. Probably other email hosts do the same. When you create a test account you need to introduce: first name, last name, email address, password, secret question, secret answer, date of birth, and iTunes store country. You can put exactly the same data (including password) for tester+01@gmail.com and tester+02@gmail.com and you will have two test accounts. Finally, in your tester@gmail.com inbox you will receive two verification emails from Apple to confirm both test accounts.

    2. Say that you have a non-consumable with product ID @"Extra_Levels". Instead of writing @"Extra_Levels" in all methods (requestProduct, purchaseProduct, ...), just write PRODUCT_ID1 and at some header file put #define PRODUCT_ID1 @"Extra_Levels" (with no semicolon!), then the preprocessor will search PRODUCT_ID1 and substitute it for @"Extra_Levels". Then creating a new non-consumable called @"Extra_Levels_01" and changing the #define will be as good as resetting the purchases for all your test users.

    3. As appsmatics pointed out, you can test the correct behavior of your code when you buy a non-consumable IAP by first using a consumable IAP (so that test user can make as many purchases as needed) to get rid of some bugs. Of course, you should also test the code with the real non-consumable IAP after that.

    0 讨论(0)
提交回复
热议问题