Integrate RevenueCat subscription status with OneSignal


The OneSignal integration is available on the Pro plan.

RevenueCat can automatically update user tags in OneSignal with their latest subscription status. This can be helpful in understanding what stage a customer is in to react accordingly. For example, you might want to:

  • Send an onboarding campaign to a user in a free trial
  • Send a push notification to churned users and offer them a discount

With accurate and up-to-date subscription data in OneSignal, you'll be set to turbo charge your campaigns.

For every auto-renewing subscription event in RevenueCat, the following tags get added or updated on the user in OneSignal. By leaving the tag blank in the RevenueCat dashboard, you can choose to not send any value for specific tag(s).

app_user_idThe RevenueCat App User Id that triggered the event
period_typeThe latest period type for the purchase or renewal. Either:
- TRIAL (for free trials)
- INTRO (or introductory pricing)
- NORMAL (standard subscription)
purchased_atepoch time in seconds of the latest subscription purchase or renewal
expiration_atepoch time in seconds of the latest subscription expiration date
environmentEither SANDBOX or PRODUCTION
last_event_typeThe latest event type from the user. Either:
product_idThe latest subscription product identifier that the user has purchased or renewed
entitlement_idsComma separated string of RevenueCat Entitlement identifiers that the user unlocked
active_subscriptionThe value will be set to true on any purchase/renewal event, and false on EXPIRATION
grace_period_expiration_atIf a billing issue occurs we will send the date of the grace period expiration.


Auto-renewing subscriptions only

RevenueCat only updates data tags in OneSignal in response to auto-renewing subscription events.

1. Send device data to RevenueCat

The OneSignal integration requires some device-specific data. RevenueCat will only update users in OneSignal if the below data has been added as Subscriber Attributes for the user.

$onesignalIdThe OneSignal Player Id for the user.

This property can be set manually, like any other Subscriber Attributes, or through the helper method setOnesignalID().

You can listen for changes to the OneSignal Id through their SDK, and send the value to RevenueCat. If you already have OneSignal set up, you should make sure that you're also sending the OneSignal Id for users that are updating to the latest version of your app.

class AppDelegate: UIResponder, UIApplicationDelegate, OSSubscriptionObserver {

    var window: UIWindow?

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        Purchases.configure(withAPIKey: "<revenuecat_api_key>", appUserID: nil)
        OneSignal.initWithLaunchOptions(launchOptions, appId: "<onesignal_app_id>")
        OneSignal.add(self as OSSubscriptionObserver)
        // If you've already set up OneSignal, then users should already have
        // a OneSignal Id. We can check if it's available and send it to RevenueCat
        if let onesignalId = OneSignal.getUserDevice()?.getUserId() {
        return true

    // Add this method to update the $onesignalId in RevenueCat whenever it changes
    // This code should be sufficient to capture all new users if you're setting
    // up OneSignal for the first time.
    func onOSSubscriptionChanged(_ stateChanges: OSSubscriptionStateChanges!) {
        if !stateChanges.from.subscribed && {
            // The user is subscribed
            // Either the user subscribed for the first time

2. Send RevenueCat events into OneSignal

After you've set up the Purchases SDK to send device data to RevenueCat, you can "turn on" the integration and configure the tag names from the RevenueCat dashboard.

  1. Navigate to your project in the RevenueCat dashboard and find the Integrations card in the left menu. Select + New
  1. Choose OneSignal from the Integrations menu.
  2. Add your OneSignal App Id and OneSignal API key.
  3. Enter the tag names that RevenueCat should use, or choose the default tag names.

OneSignal configuration screen

3. Testing the OneSignal integration

You can test the OneSignal integration end-to-end before going live. It's recommended that you test the integration is working properly for new users, and any existing users that may update their app to a new version.

Make a sandbox purchase with a new user

Simulate a new user installing your app, and go through your app flow to complete a sandbox purchase.

Check that the required device data is collected

Navigate the the Customer View for the test user that just made a purchase. Make sure that all of the required data from step 1 above is listed as attributes for the user.

Check that the OneSignal event delivered successfully

While still on the Customer View, click into the test purchase event in the Customer History and make sure that the OneSignal integration event exists and was delivered successfully.



Why are tags not working?

If your tags aren't working and RevenueCat is sending events successfully with 200 codes, check out OneSignal's troubleshooting guide.


You've done it!

You should start seeing subscription data from RevenueCat appear on users in OneSignal.