Sandbox: Is possible to simulate a failed or interrupted In App Purchase?

爷,独闯天下 提交于 2019-12-21 05:08:27

问题


I have recently implemented In App Purchasing in my app. Good thing Apple has documented the whole process very well.

Using those docs, I'm finally able to test In App Purchasing through the Sandbox, which is a very convenient feature. I have successfully tested my app so that it reacts to whatever the StoreKit returns when I tap the buyButton.

Now here's my question. From the docs, it says that the Sandbox simulates the transaction process with no financial stuff. So I'm free to buy as much as I want (by the way, I'm buying consumables and only consumables). Also, the Sandbox will ALWAYS simulate a successful transaction, no matter what. So, is it possible to have the Sandbox simulate a failed transaction, and better yet, an interrupted transaction?

I want to do that to trap possible errors when those events happen (although I've read somewhere that StoreKit already handles that) and display them on the screen (at the very least), just to inform the user what's happening during the transaction process.

Thanks in advance.


回答1:


An easy way to simulate lots of common networked transaction problems is to unplug the network cable from the back side of the wifi access point being used at various points in the process. You could try stuff like unplugging the wifi's WAN cable, then use alternate or cabled access to remove your IAP from availability in iTunes Connect, then re-enable wifi access.




回答2:


The best way to simulate various networked situations is with the Network Link Conditioner utility. It is event mentioned in Apple documentation regarding networked operation testing.

That way you are not dependant from shared access points, or your co-workers interfering with your tests. You also can easily simulate a lot more situations than just connected/not connected.

Here is a step-by-step on how to install it and use it on both OSX (for testing in simulator) and iOS.



来源:https://stackoverflow.com/questions/12836387/sandbox-is-possible-to-simulate-a-failed-or-interrupted-in-app-purchase

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!