Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Unpredictable Sandbox Environment for IAP Auto-renewable Subscriptions

188a42adbd815a746df557c7dc72566a?s=47 denkeni
November 09, 2020

Unpredictable Sandbox Environment for IAP Auto-renewable Subscriptions

188a42adbd815a746df557c7dc72566a?s=128

denkeni

November 09, 2020
Tweet

Transcript

  1. © 2020 Denken All rights reserved. Redistribution or public display

    not permitted without written permission from Denken. https://denkeni.medium.com/unpredictable-sandbox-environment-for-iap-auto-renewable-subscriptions-44461d7b1378 Unpredictable Sandbox Environment for IAP Auto-renewable Subscriptions Denken Chen, Confused iOS App Developer #WWDC20 #WorldWideDevelopersConfused20
  2. Sandbox Tester Subscription Management Billing Retry Service App Store Server

    Notification
  3. Sandbox Tester

  4. Purchase develop on simulator Sandbox /verifyReceipt develop on device Production

    /verifyReceipt develop on device
  5. Sandbox Tester On iOS 14 simulator WWDC20 Introducing StoreKit Testing

    in Xcode No Account Purchase develop on simulator Sandbox /verifyReceipt develop on device Production /verifyReceipt develop on device
  6. Sandbox Tester Only on real iOS device Just use your

    Apple ID Single Account Purchase develop on simulator Sandbox /verifyReceipt develop on device Production /verifyReceipt develop on device
  7. Sandbox Tester Create more sandbox testers on App Store Connect

    Email address that has never been used as an Apple ID Apple officially recommends using subaddressing You may still get stuck for multiple unclear reasons Multiple Accounts: Creation
  8. Sandbox Tester iOS device — Settings — iTunes & App

    Store Log out current account DO NOT log in sandbox tester account here Purchase IAP with sandbox tester account Multiple Accounts: How to Use
  9. Sandbox Tester “Important: Don’t use your test user account to

    sign in to the production environment. If you do, the test user account becomes invalid and can no longer be used.” from In-App Purchase Programming Guide — Retrieving Product Information — Suggested Testing Steps Multiple Accounts: Warning
  10. Sandbox Tester Xcode 12 App Review Purchase develop on simulator

    Sandbox /verifyReceipt develop on device Production /verifyReceipt develop on device Xcode TestFlight App Review App Store “Verify your receipt first with the production URL; proceed to verify with the sandbox URL if you receive a 21007 status code.”
  11. Subscription Management

  12. Subscription Management Xcode 12 → Subscription Options(?) Purchase develop on

    simulator Sandbox /verifyReceipt develop on device Production /verifyReceipt develop on device iOS 14 Settings → App Store → Sandbox Account iOS Settings or App Store → Profile → Subscriptions
  13. Subscription Management “Maximum” 5 automatic renewals* Usually starts with 5

    renewals, and no renewal afterwards. How long the cooldown time is? Probably hours. Auto-renewable Subscriptions * WWDC 2018 Session 704 slides P.37
  14. Billing Retry Service

  15. Billing Retry Service Recovery Rate from 30.0% to 77.4%, just

    amazing(*) is_in_billing_retry_period randomly for true DID_FAIL_TO_RENEW and DID_RECOVER notification * WWDC 2019 Session 302 slides P.215
  16. App Store Server Notification

  17. App Store Server Your Server Status Polling App Store Notifications

    Server-to-Server Notifications Status Update Notifications NSNotificationCenter Apple Push Notification Service /verifyReceipt Receipt
  18. App Store Server Notification CANCEL Indicates that either Apple customer

    support canceled the subscription or the user upgraded their subscription. (*1) This event is not the same as when the user enters their iTunes account — Subscription section, and indicates that they choose not to allow an existing auto-renewing subscription to renew. (*2, and see DID_CHANGE_RENEWAL_STATUS) RTFM (*1) https://developer.apple.com/documentation/appstoreservernotifications/notification_type (*2) https://forums.developer.apple.com/thread/98894#thread-message-301062
  19. App Store Server Notification RTFM (*1) https://developer.apple.com/documentation/appstoreservernotifications/notification_type (*2) https://forums.developer.apple.com/thread/98894#thread-message-301062 RENEWAL

    (it’s been renamed as DID_RECOVER) Indicates a successful automatic renewal of an expired subscription that failed to renew in the past. Check expires_date to determine the next renewal date and time. (*1, and see DID_RENEW) In general, iTunes will attempt to charge the user account a day before an auto-renewing subscription is scheduled to expire... in the few cases that iTunes is unable to renew the subscription (generally there was a connection problem with the credit card server)... technically considered “expired”. However, iTunes will still continue to attempt to renew the subscription. If iTunes is successful, then the “RENEWAL” event is sent. (*2)
  20. App Store Server Notification DID_CHANGE_RENEWAL_PREF Indicates that the customer made

    a change in their subscription plan that takes effect at the next renewal. (Downgrade) DID_CHANGE_RENEWAL_STATUS Indicates a change in the subscription renewal status. (Toggling auto-renew on/off.) INTERACTIVE_RENEWAL Indicates the customer renewed a subscription interactively, ... (Upgrade or renew) RTFM * https://developer.apple.com/documentation/appstoreservernotifications/notification_type * https://developer.apple.com/videos/play/wwdc2020/10661/?time=14m19s
  21. App Store Server Notification RTFM * https://developer.apple.com/wwdc20/10661?time=16m52s

  22. Summary Beware of sandbox tester creation Subscription Management is okay

    in 2020 Billing Retry Service is okay in 2020 App Store Server Notification — RTFM