iOS In-App purchasing and subscriptions : Testing

2019-03-14 05:14发布

A college of mine has implemented iOS in-app purchasing on a auto-renewing monthly basis. I am taking over the code base and want to test it is working. I know the purchasing is wokring but the auto-renewing is what I am worried about.

I have set up a test user and read the Apple documentation that says in sandbox mode, a month is 5 minutes in the sandbox.

However I am not getting any post back from Apple after 5 minutes? should I?

In the AppDelegate I have

 inAppPurchase = [TFInAppPurchase new];
[[SKPaymentQueue defaultQueue] addTransactionObserver:inAppPurchase];
[inAppPurchase updateAvailableProductsCache];

I am expecting after 5 minutes, it to fire of a notification or something?

3条回答
SAY GOODBYE
2楼-- · 2019-03-14 05:45

No notification will be generated by apple. You have to save the recipes on server or device by using nsuserdefaults or keychain. you have to track the duration by yourself.By caluclating Compare the product identifier in question to the product identifier of each in-app purchase receipt. If there is a receipt that matches, validation succeeds. Otherwise, validation fails.

When validation succeeds, your application enables the purchased functionality—for example, by downloading content or adding features. When validation fails, your application simply does not enable the functionality.

查看更多
仙女界的扛把子
3楼-- · 2019-03-14 05:51

There is no notification. You keep track of it yourself (the duration). You get a receipt with the original transaction that you save. Use this to verify (perhaps on launch each time) that the user's subscription is still active.

查看更多
三岁会撩人
4楼-- · 2019-03-14 05:55

In the iTunes development guide, there's list of how long auto-renew subscriptions last in sandbox mode:

Sandbox Testing Your In-App Purchases

You are required to test your in-app purchases in a sandbox environment before you submit them for review by Apple. You must first sign out of your iTunes Store account from your test device Settings before attempting to use the sandbox environment. If you mistakenly use your test-user-account credentials to log in to a production environment on your test device (instead of in to your test environment), your account credentials become invalid and cannot be used as a test account again. For more details on how to avoid mistakes during test account use, see “Using Test User Accounts.”

When testing auto-renewable in-app purchase subscriptions in the sandbox environment, the duration times will be compressed to allow for more streamlined testing. Additionally, a sandbox subscription will only auto-renew a maximum of 6 times. After the subscription has auto-renewed 6 times, it will no longer renew in the sandbox. The compressed duration times are as follows:

   Actual duration      Sandbox duration
   1 week               3 minutes 
   1 month              5 minutes
   2 months             10 minutes 
   3 months             15 minutes 
   6 months             30 minutes 
   1 year               1 hour
查看更多
登录 后发表回答