Mobile apps primarily rely on two monetization strategies: ads and subscriptions. While ads provide free access to users and generate revenue for developers, they often disrupt the user experience and can lead to frustration. This creates an opportunity for developers to offer a premium, ad-free experience through subscriptions—a win-win solution that enhances user satisfaction while generating recurring revenue.

In this guide, we’ll walk you through the process of implementing an ad-free subscription in your React Native app using RevenueCat. This tutorial is beginner-friendly. Here’s what we’ll cover:

  • Adding react-native-purchases to enable in-app purchasing in our app
  • Adding react-native-google-mobile-ads to display inline ads in our app
  • Configuring in-app products in RevenueCat and required entitlements that unlock the ad-free experience

Track ad revenue in RevenueCat

You can now track your AdMob add revenue in Revenuecat and get a complete picture of your revenue. Simply replace your standard AdMob loading calls with the loadAndTrack methods from the RevenueCat SDK. All ad events are tracked automatically. Read more about our new in-app ad revenue in our announcement blog post.

Prerequisites

Next let’s add some lovely ads to our app

In this tutorial, we will build a simple React Native app, for both iOS and Android, that allows the user to subscribe to a monthly subscription which unlocks an ad-free experience in the app. If you have an existing app which you’re going to implement subscription functionality, you can jump ahead to the next section. Follow along by cloning the sample project, built with Expo.

When using react-native-purchases with Expo you need to install expo-dev-tools and create a development build as Expo Go does not support native modules which are required by react-native-purchases. Learn how to create a development build and install it on your device from this interactive guide

Start by cloning this GitHub repository which contains the template for this project.

git clone git@github.com:plahteenlahti/ad-iap-example.git

The template comes configured with Expo, react-native-google-mobile-ads, and expo-dev-client. Expo Go doesn’t support native modules by default, which are required for react-native-purchases. Run npm install to install all the dependencies and open the project in your editor of choice. After that, run npx expo start to start the development server.

Testing in-app purchases is best on a real device, so choose that option from the above list and you should see something like this:

Step 1: Set up App Store and Play Store

Before we can move to implementing subscriptions in our app, we need to configure our subscription product for all the platforms we want to target. Since React Native is a cross-platform solution, targeting both iOS and Android is a good idea. In both cases we want to configure a single subscription: a monthly recurring subscription for 5 dollars.

Step 1.1: Set up App Store

Create a RevenueCat account and then follow this guide to connect the App Store to RevenueCat.

Step 1.2: Set up Play Store

Create a RevenueCat account and then follow this guide to connect the Play Store to RevenueCat.

Step 2: Set up RevenueCat products

Once you’ve configured the store of your choice, or both, it’s time to set up Revenuecat. If you’re not familiar with Revenuecat before, or time has passed since the last time you used it, this quickstart guide will help you get up to speed.

You should configure your RevenueCat products, offerings and entitlements so that you have:

  • One entitlement for the ad-free subscription level, using the identifier ad_free_entitlement
  • Two separate products for App Store and Play Store, for example with identifier ad_free_monthly (learn more about the naming practises: iOS, Android)
  • Matching subscriptions in Play Store console and App Store connect with the same identifiers

Remember to group your product under the entitlement you created.

Step 3: Add ads with react-native-google-mobile-ads

Next let’s add some ads to our app. First we need to install the react-native-google-mobile-ads. Use the command below

npx expo install react-native-google-mobile-ads

Also install expo-build-properties:

npx expo install expo-build-properties

We also need to enable static frameworks for everything to work. In your app.json, add the following plugin configuration:

{
  "expo": {
    "name": "Ad-free reader",
    "slug": "ad-free-reader",
    "plugins": [
      [
        "react-native-google-mobile-ads",
        {
          "iosAppId": "ca-app-pub-3940256099942544~1458002511",
          "androidAppId": "ca-app-pub-3940256099942544~3347511713"
        }
      ],
      [
        "expo-build-properties",
        {
          "ios": {
            "useFrameworks": "static"
          }
        }
      ]
    ]
  }
}

Before displaying ads, you’ll need a Google AdMob account. Create one if you haven’t already and create new apps in the AdMob dashboard for all the platforms you plan to target. Notice that you need to place your AdMob key in the config plugin’s section. Using an invalid key will cause your app to crash.

Run your app and ensure that everything is working properly. The next step is to add the correct type of ads into our app.

Initialize the Google Mobile Ads SDK

Before you can load ads in your app, you need to initialize the Google Mobile Ads SDK by calling the initialize method. This call needs to be done only once, preferably right after the app launch.

In your app entrypoint (_layout.tsx in Expo router or App.tsx in bare project) do the following:

import { Stack } from "expo-router";
import { useEffect } from "react";
import { Platform } from "react-native";
import mobileAds from "react-native-google-mobile-ads";

export default function RootLayout() {
  useEffect(() => {
    // Initialize mobile ads
    mobileAds()
      .initialize()
      .then(adapterStatuses => {
        console.log('Mobile ads initialized successfully');
      })
      .catch(error => {
        console.error('Failed to initialize mobile ads:', error);
      });

  }, []);

  return <Stack screenOptions={{ title: "Article" }} />;
}

You also need to take care of requesting app tracking transparency authorization. Follow React Native Google Mobile Ads documentation for doing that correctly.

Show banner apps in your app

React native Google Mobile Ads provides multiple different types of ads to show in your app. In our case we want to show banner ads that take a limited amount of space on the screen, allowing the user to still see the main content but with a slightly hindered user experience.

Banner ads work like this:

  • You import the BannerAd component and include it in the code. In the example project there is an existing Ad component that we can place the BannerAd component in.
  • Since BannerAd is a WebView we need to call the useForeground hook to detect when app is brought back from background and request a new ad so that banner ads don’t end up showing empty ads.
  • Define unitId and size. The former should in testing be a TestIds.ADAPTIVE_BANNER and in production a real ad id, while the latter should be of the size we want to show in our app. In the example an adaptive banner size is used

Add the following snippet to your code to show banner ads:

Ad.tsx
import { useRef } from 'react';
import { Platform, View } from 'react-native';
import { BannerAd, BannerAdSize, TestIds, useForeground } from 'react-native-google-mobile-ads';

export function Ad() {
  const bannerRef = useRef<BannerAd>(null);
  useForeground(() => {
    if (Platform.OS === 'ios') bannerRef.current?.load();
  });
  return (
    <View style={{ alignItems: 'center', marginVertical: 16 }}>
      <BannerAd ref={bannerRef} unitId={TestIds.ADAPTIVE_BANNER}
        size={BannerAdSize.ANCHORED_ADAPTIVE_BANNER}
        onAdFailedToLoad={error => console.warn('Banner unavailable:', error.code)} />
    </View>
  );
}

Your app should now display banner ads between the main content blocks, and look like this now:

Step 4: Add subscriptions to your React Native app

Now that we have ads configured it’s time to add react-native-purchases and react-native-purchases, RevenueCat’s SDKs for in-app purchasing. Run the command below:

npx expo install react-native-purchases@11.0.4 react-native-purchases-ui@11.0.4

If you run into problems with the setup, see this for guidance.

We want RevenueCat to be initialized on app start, add this piece of code to entry file of your app, in our example project that means the layout file:

app/_layout.tsx
import { useEffect, useState } from 'react';
import { ActivityIndicator, Platform, Text } from 'react-native';
import { Stack } from 'expo-router';
import Purchases from 'react-native-purchases';
import mobileAds from 'react-native-google-mobile-ads';

// Complete consent/ATT setup before initializing ads in a production app.
export default function RootLayout() {
  const [ready, setReady] = useState(false);
  const [error, setError] = useState('');
  useEffect(() => {
    let mounted = true;
    async function initialize() {
      const apiKey = Platform.select({
        ios: process.env.EXPO_PUBLIC_RC_IOS_KEY,
        android: process.env.EXPO_PUBLIC_RC_ANDROID_KEY,
      });
      if (!apiKey) throw new Error('Missing native RevenueCat SDK key.');
      if (!(await Purchases.isConfigured())) Purchases.configure({ apiKey });
      await mobileAds().initialize();
      if (mounted) setReady(true);
    }
    initialize().catch(() => { if (mounted) setError('Could not initialize purchases and ads.'); });
    return () => { mounted = false; };
  }, []);
  if (error) return <Text>{error}</Text>;
  if (!ready) return <ActivityIndicator />;
  return <Stack screenOptions={{ title: 'Article' }} />;
}

This code runs on app mount. Set the platform-specific EXPO_PUBLIC_RC_IOS_KEY and EXPO_PUBLIC_RC_ANDROID_KEY environment variables with your RevenueCat Project Settings keys. If you see RevenueCat error logs in the console, review and fix them.

Checking user entitlements

To keep track whether a user has purchased a subscription and is eligible for ad-free experience, we implement a custom hook for checking the subscription status. Add this code for in a separate file called useIsAdFree.ts

Import the hook in index.tsx, make the following changes to the app code, and save them. Most things should be the same now, but you should see a loader when the app loads.

Implement purchasing functionality

Now that we can check if a user has purchased a subscription, it’s time to implement the purchasing functionality. The complete ArticleScreen.tsx below includes purchasing and restoring:

In a real case you should handle the error differently, but this works for now, since we’re only using a single product in our app for now.

Next, use the complete ArticleScreen.tsx code, which includes purchase and restore buttons:

useIsAdFree.ts
import { useEffect, useState } from 'react';
import { AppState } from 'react-native';
import Purchases, { type CustomerInfo } from 'react-native-purchases';

export function useIsAdFree() {
  const [adFree, setAdFree] = useState<boolean | null>(null);
  const [error, setError] = useState('');
  useEffect(() => {
    let mounted = true;
    const update = (info: CustomerInfo) => {
      if (!mounted) return;
      setAdFree(info.entitlements.active['ad_free_entitlement'] !== undefined);
      setError('');
    };
    const refresh = () => Purchases.getCustomerInfo().then(update).catch(() => {
      if (mounted) setError('Could not check your subscription. Please retry.');
    });
    Purchases.addCustomerInfoUpdateListener(update);
    const subscription = AppState.addEventListener('change', state => {
      if (state === 'active') void refresh();
    });
    void refresh();
    return () => {
      mounted = false;
      subscription.remove();
      Purchases.removeCustomerInfoUpdateListener(update);
    };
  }, []);
  return { adFree, loading: adFree === null && !error, error };
}
ad-free-screen.tsx
import { useState } from 'react';
import { ActivityIndicator, Button, ScrollView, Text } from 'react-native';
import Purchases from 'react-native-purchases';
import RevenueCatUI, { PAYWALL_RESULT } from 'react-native-purchases-ui';
import { useIsAdFree } from './useIsAdFree';
import { Ad } from './Ad';

export default function ArticleScreen() {
  const { adFree, loading, error } = useIsAdFree();
  const [busy, setBusy] = useState(false);
  const [message, setMessage] = useState('');
  async function run(action: () => Promise<void>) {
    setBusy(true);
    try { await action(); }
    catch { setMessage('Could not complete the request. Please retry.'); }
    finally { setBusy(false); }
  }
  if (loading) return <ActivityIndicator />;
  return (
    <ScrollView contentContainerStyle={{ padding: 16 }}>
      <Text>{message || error}</Text>
      <Text>Your article content goes here.</Text>
      {adFree === false && !error && <Ad />}
      {adFree !== true && <Button title="Remove ads" disabled={busy}
        onPress={() => { void run(async () => {
          const result = await RevenueCatUI.presentPaywall({ displayCloseButton: true });
          if (result === PAYWALL_RESULT.ERROR) throw new Error('Paywall failed.');
          // The CustomerInfo listener refreshes access after purchase/restore.
          await Purchases.getCustomerInfo();
        }); }} />}
      <Button title="Restore purchases" disabled={busy}
        onPress={() => { void run(async () => {
          const info = await Purchases.restorePurchases();
          setMessage(info.entitlements.active['ad_free_entitlement']
            ? 'Ad-free access restored.' : 'No active ad-free subscription found.');
        }); }} />
    </ScrollView>
  );
}

Test your app by pressing on the button and buying the subscription. If all goes well, you should see a loader after which the ads disappear and you can enjoy your content ad free.

Conclusion

Nice job, you’ve reached the end of this tutorial and you now have an app allowing users to subscribe to unlock an ad-free reading experience. Although this is a very good start, getting your app accepted for distribution will require testing purchases and restoring them on real devices. We’ve collected some additional reading here for you to continue building the best possible in-app purchases experience: