Showing a Manage Subscriptions Button in React Native

If you implement in-app purchases in your app, you might want to show users a way to manage that subscription by showing links to the App Store or Google Play app.

In native Swift, on the iOS side, there is StoreKit to do this, and Android has similar APIs. If you're using React Native, however, you might prefer to just deep link to the right URL.

Code example

A very simple approach to doing this looks as follows:

import React from "react";
import { Button, Linking, Platform } from "react-native";

const APP_ID = "com.example.myapp";
const IAP_PRODUCT_ID = "yearly-subscription";

const ManageSubscriptionButton = () => {
	const manageSubscriptionUrl = Platform.select({
		android: `https://play.google.com/store/account/subscriptions?sku=${IAP_PRODUCT_ID}&package=${APP_ID}`,
		ios: "https://apps.apple.com/account/subscriptions",
	});
	
	return (
		<Button
			title="Manage subscription"
			onPress={() => Linking.openURL(manageSubscriptionUrl)}
		/>
	);
}

References