且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

清除针对测试用户的IOS应用内购买沙箱中的购买

更新时间:2022-12-31 09:38:09

IMO有三件事可以让非耗材测试可以忍受:

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


  1. 您可以将多个测试帐户与一封电子邮件相关联。例如,Gmail允许您向电子邮件添加加字符串以创建地址的别名:所以 tester+01@gmail.com tester+02@gmail.com 两者都只是去 tester@gmail.com 。可能其他电子邮件主机也会这样做。当您创建测试帐户时,您需要介绍:名字,姓氏,电子邮件地址,密码,秘密问题,秘密答案,出生日期和iTunes商店国家/地区。您可以为 tester+01@gmail.com tester+02@gmail.com $ c提供完全相同的数据(包括密码) $ c>,您将拥有两个测试帐户。最后,在您的 tester@gmail.com 收件箱中,您将收到Apple提供的两封验证电子邮件,以确认这两个测试帐户。

  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.

假设您有一个产品ID为Extra_Levels的非消耗品。而不是在所有方法(requestProduct,purchaseProduct,...)中编写@Extra_Levels,只需编写 PRODUCT_ID1 并在某些头文件中输入 #define PRODUCT_ID1 @Extra_Levels(没有分号!),然后预处理器将搜索PRODUCT_ID1并将其替换为@Extra_Levels。然后创建一个名为@Extra_Levels_01的新非消耗品并更改#define将与重置所有测试用户的购买一样好。

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.

As appsmatics指出,当您通过首先使用可消耗的IAP(以便测试用户可以根据需要进行尽可能多的购买)购买非消耗性IAP时,您可以测试代码的正确行为,以消除一些错误。当然,您之后还应该使用真正的非消耗性IAP测试代码。

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.