OneSignal

Learn how to set up integration with OneSignal

We use subscription events to update OneSignal tags, so you can build target communication with customers using OneSignal push notifications after a short and easy integration setting as described below.

To integrate OneSignal go to Integrations > OneSignal, turn on a toggle from off to on, and fill out fields.

1. Credentials

First of all set credentials to build a connection between your OneSignal and Adapty profiles.
OneSignal app ID and auth key are required.

887

Required credentials in Adapty

They can be found in your OneSignal dashboard.

App ID - in the Keys & IDs section.

986

OneSignal App ID in OneSignal

Auth key - in the Account & API keys section

863

Auth key in OneSignal dashboard

2.Events and tags

Below the credentials, there are three groups of events you can send to OneSignal from Adapty. Simply turn on the ones you need.

934

Subscriptions, trials, issues events in Adapty integration interface

These Adapty events work like triggers for user profile's tags update in OneSignal. Please look at the list of tags below to see which one is fitiing to your requirements.

🚧

Please consider that starting from April 17th, 2023, it will not be possible to send attribution data from Adapty to OneSignal, if you are using the Free Plan of OneSignal. This integration is only available for OneSignal's Growth, Professional and higher plans. For more info kindly check OneSignal pricing..

📘

Custom tags

With Adapty you can also use your custom tags for OneSignal integration. Feel free to do so.

TagTypeValue
adapty_customer_user_idStringcustomer user id
adapty_profile_idStringprofile id
environmentStringdev or prod environment link
storeStringAppstore, Google play
vendor_product_idStringid of the purchased subscription
subscription_expires_atStringthe expiration date of the subscription
last_event_typeStringthe type of the last received event from the list of the standard Adapty events
purchase_dateStringthe date of purchase
original_purchase_dateStringthe date of the first purchase according the transaction
active_subscriptionStringHas user got an active subscription? True or false
period_typeStringIs it trial or not? True or false

All float values will be rounded to int. Strings stay the same.

3. SDK configuration

🚧

Make sure you send playerId to Adapty, otherwise OneSignal tags couldn't be updated and the integration wouldn't work.

To link Adapty with OneSignal you need to send us the playerId value:

// in your OSSubscriptionObserver implementation

func onOSSubscriptionChanged(_ stateChanges: OSSubscriptionStateChanges) {
    if let playerId = stateChanges.to.userId {
          let params = AdaptyProfileParameters.Builder()
              .with(oneSignalPlayerId: playerId)
              .build()

          Adapty.updateProfile(params:params) { error in
              // check error
          }
    }
}
val osSubscriptionObserver = OSSubscriptionObserver { stateChanges ->
    stateChanges?.to?.userId?.let { playerId ->
        val params = AdaptyProfileParameters.Builder()
            .withOneSignalPlayerId(playerId)
            .build()
      
        Adapty.updateProfile(params) { error ->
            if (error != null) {
                // handle the error
            }
        }
    }
}
OSSubscriptionObserver osSubscriptionObserver = stateChanges -> {
    OSSubscriptionState to = stateChanges != null ? stateChanges.getTo() : null;
    String playerId = to != null ? to.getUserId() : null;
    
    if (playerId != null) {
        AdaptyProfileParameters params1 = new AdaptyProfileParameters.Builder()
                .withOneSignalPlayerId(playerId)
                .build();
        
        Adapty.updateProfile(params1, error -> {
            if (error != null) {
                // handle the error
            }
        });
    }
};

Read more about OSSubscriptionObserver in OneSignal documentation.

4. Dealing with multiple devices

One can often encounter the following situation: a single user has different devices and analytics of purchase events or user subscriptions becomes difficult. OneSignal suggests methods to cope with this problem. You can match different devices on your server side and send this information to OneSignal. Thus, when you change user's tags, they will be updated not only for a specific device but for all devices the user has.
Adapty leverages this opportunity to help you match user's devices. You can identify user using Adapty SDK and also send your id to OneSignal. After that, we will be able to update tags for multiple users without any extra actions.