Interview frequency: …
Short answer
Use the RevenueCat platform and library (react-native-purchases) to manage subscriptions on iOS and Android through one API that handles receipt validation, renewals, and grace periods.
Explanation
Managing subscriptions directly through Apple StoreKit and Google Play Billing is difficult because of complex cases such as cancellation, refunds, expired cards, and upgrades. RevenueCat provides ready-made hooks and secure server responses, and checks entitlement status immediately to enable paid features for the user.
Code example
import Purchases from 'react-native-purchases';
async function initIAP(userId: string) {
Purchases.configure({ apiKey: "public_revcat_key", appUserID: userId });
}
async function buyProSubscription(packageToBuy: any) {
try {
const { customerInfo } = await Purchases.purchasePackage(packageToBuy);
if (customerInfo.entitlements.active['pro_access']) {
// Successfully enable paid-account features
}
} catch (e: any) {
if (!e.userCancelled) console.error(e);
}
}Common mistakes
- Trusting a purchase receipt directly from the user's device without verifying it through a secure backend, allowing fraudulent purchases with hacking tools.