React Native - Subscriptions (iOS)


IC
iTunes Connect
IAP
in-app purchase

  1. Workflow for configuring in-app purchases
  2. In-App Purchase Programming Guide
  3. https://www.raywenderlich.com/154737/app-purchases-auto-renewable-subscriptions-tutorial
  4. https://distriqt.github.io/ANE-InAppBilling/s.Apple%20In-App%20Purchases

implement subscriptions in application

  1. https://github.com/chirag04/react-native-in-app-utils
  2. https://github.com/sibelius/iap-receipt-validator
  3. Adding In-App Purchase to Your Applications
  4. Validating Receipts With the App Store
  5. Receipt Fields

obtain a shared secret

IC
My Apps<MY_APP>Features (tab)
In-App Purchases (left menu) → App-Specific Shared SecretView Master Shared Secret (link)

shared secret is used to validate receipts with iap-receipt-validator npm package.

add subscription in IC

create IAP

IC
My Apps<MY_APP>Features (tab)
In-App Purchases (left menu) → In-App Purchases (section) → (link)

Select the in-app purchase you want to create.

Create Auto-Renewable Subscription

Create Subscription Group

configure IAP

IC
My Apps<MY_APP>Features (tab)
In-App Purchases (left menu) → <subscription> (link)

https://developer.apple.com/library/content/technotes/tn2259/_index.html#//apple_ref/doc/uid/DTS40009578-CH1-ITUNES_CONNECT:

Leave the state of your product as Missing Metadata.

Upload a a screenshot of your in-app purchase product once you are done testing it and ready to upload it for review.

configure subscription group

IC
My Apps<MY_APP>Features (tab)
<subscription_group> (link)

it’s required to add localization for subscription group as well:

Before you can submit your in-app purchase for review, you must add at least one localization to your subscription group.

test subscription on real device

  1. React Native - Running on Real Device

it’s required to run application on real device to make purchases: the only action allowed from inside emulator is loading products.

test subscriptions:

test subscriptions are not created separately - they are real subscriptions but with special characteristics and behaviour for sandbox testers.

https://forums.developer.apple.com/thread/14702:

the sandbox environment handles auto-renewing subscriptions in an automated fashion - that is subscription periods are shortened and renew only 5 times and not controlled through the subscription management screen.

sandbox testing

add sandbox testers (sandbox tester accounts)

  1. https://support.magplus.com/hc/en-us/articles/203809008-iOS-How-to-Test-In-App-Purchases-in-Your-App

NOTE: it’s not required to use sandbox testers to check subscription status (skip this section if all you want is to check subscription status).

IC
Users and AccessSandboxTesters (left menu) → (link)

tips and notes regarding sandbox tester:

about verification of sandbox tester email

generally speaking it’s necessary to verify new sandbox tester account by following the link sent to specified email:

You must validate your e-mail, or any purchases you make will silently fail.

but I couldn’t verify account of a new sandbox tester - after clicking the link email verification page kept on loading forever with an activity indicator in the middle of the screen and JS errors in Chrome Console:

bundle.js:46270 Refused to create a worker from 'blob:https://id.apple.com/...'
because it violates the following Content Security Policy directive...

IDK if it matters or not but I signed in to iCloud with this account (in browser) and completed registration by adding 3 secret questions.

in the end I could make a purchase using not verified sandbox tester account.

UPDATE (2018-03-19)

I have successfully verified email of another sandbox tester - most likely it was temporary technical problem on Apple side.

set environment in application

sandbox tester can purchase a test subscription in production environment but subscription status cannot be checked since sandbox receipt cannot be validated in production environment (see troubleshooting section for details):

NOTE: there were lots of Network request failed errors when purchasing a test subscription => keep on trying.

run application on real device

  1. React Native - Running on Real Device
  2. http://pinkstone.co.uk/deploying-your-app-from-xcode-to-a-device-with-release-build-configuration/

run application in Xcode (in debug or release mode):

Xcode
(toolbar button)

troubleshooting

beta testing

IC
My Apps<MY_APP>TestFlight (tab)
All Testers (left menu)

beta testers (or just testers) are IC users who are invited to test TestFlight builds - that is they must have been already added before. just like sandbox testers they:

NOTE: beta testers can’t buy subscription even if it’s approved in IC.

install application from TestFlight

when beta tester is making a purchase, all Apple dialogs no longer have the line [Environment: Sandbox] (like for sandbox testers).

publish release with subscription

fill review information

  1. https://stackoverflow.com/questions/4802810/iphone-in-app-purchase-screen-shot/4803012
  2. https://developer.apple.com/app-store/review/guidelines/
  3. https://help.apple.com/itunes-connect/developer/#/dev84b80958f
IC
My Apps<MY_APP>Features (tab)
In-App Purchases (left menu) → <subscription> (link) → Review Information (section)

after you fill review information, subscription status is automatically changed from Missing Metadata to Ready to Submit.

create new app version

IC
My Apps<MY_APP>App Store (tab)
⨁ VERSION OR PLATFORM (link in left menu) → iOS (popup menu)

new app version has Prepare for Submission status now.

add IAP to new app version

In-App Purchases page:

Your first in-app purchase must be submitted with a new app version. Select it from the app’s In-App Purchases section and click Submit.

Once your binary has been uploaded and your first in-app purchase has been submitted for review, additional in-app purchases can be submitted using the table below.

  1. https://stackoverflow.com/a/42191936/3632318
IC
My Apps<MY_APP>App Store (tab)
3.14 Prepare for Submission (left menu) → In-App Purchases (section) → (link)

NOTE: In-App Purchases section is available only if you’ve created IAP before.

release new app version

according to iTunes Store email received after releasing new app version:

It can take up to 24 hours before your app is available on the App Store.
This delay is dependent on any app availability issues

in fact it took about 30 minutes for new app version to appear in the App Store.

troubleshooting

view financial reports

IC
App AnalyticsOverview (tab)
In-App Purchases (widget) or Sales (widget)
IC
App AnalyticsMetrics (tab)
In-App Purchases (left menu) or Sales (left menu)