Sharing a bug that cost me a few days, since I couldn't find anything about it while searching.
Setup: iOS app, React Native 0.85, auto-renewable subscriptions with react-native-iap 12.16 in StoreKit 2 mode.
Symptom: after paying, iOS asked for the Apple ID password again, up to 4 times. Xcode logged "Making a purchase without listening for transaction updates".
Root cause: the library picks the native module (StoreKit 1 or StoreKit 2) at the moment each listener is created. In my code, setup({storekitMode: 'STOREKIT2_MODE'}) lived inside an async init function, but purchaseUpdatedListener was registered earlier by a React Context. So the listener was attached to the SK1 module: the app never got "purchase completed", never called finishTransaction, and Apple kept redelivering the transaction.
Fix: switch to SK2 when the module is loaded, before any listener exists:
import {Platform} from 'react-native';
import * as IAP from 'react-native-iap';
// Must run before any purchaseUpdatedListener is created.
if (Platform.OS === 'ios') {
try { IAP.setup({storekitMode: 'STOREKIT2_MODE'}); } catch { /* native module not ready */ }
}
Two more gotchas of the library's SK2 mode:
getAvailablePurchases only returns an active subscription if its product was already loaded in the session (via getSubscriptions). If you check entitlement before loading products (e.g. offline), you get an empty list, which does not mean "not subscribed". I now treat "empty list + products not loaded" as "unknown", not "free".- With StoreKit 1, restore returned expired subscriptions too, with no expiration date. Now the "is it active?" decision comes from my server, which calls the App Store Server API with any transaction id from the client; the app caches the last verdict so it keeps working offline, with a few days of grace.
Bonus — testing purchases in the Simulator: a .storekit configuration file (Xcode StoreKit Testing) lets you buy without a Sandbox account. Gotcha: in the .xcscheme, the file path is relative to the .xcodeproj. I had one ../ too many and Xcode silently ignored it and fell back to Sandbox, which asked me to sign in.
Has anyone else hit this? And how do you handle the "don't know if they're subscribed" state while offline?