OneSignal

This guide describes how to add and configure OneSignal integration.

About Integration

Apphud can update User Tags in OneSignal. Tags are key-value attributes that allow you to target specific users or groups using Segments and send personalized messages with Tag Substitution.

How to Add Integration?

Step 1

Step 2

At Apphud go to "Integrations" section and add OneSignal:

Step 3

Enter Application ID and Sandbox Application ID (optional):

Step 4

You can enter your custom event names or disable some:

Step 5

Enable integration and click Save:

Match User IDs

You should set Apphud User ID property to OneSignal's externalUserID property:

Swift

// assuming both Apphud and OneSignal SDKs are initialized:
OneSignal.login(Apphud.userID())
// assuming both Apphud and OneSignal SDKs are initialized:
[OneSignal login:Apphud.userID];
// assuming both Apphud and OneSignal SDKs are initialized:
OneSignal.login(Apphud.userID())

Data Tags

Apphud sends the following payload in each event. Despite default tags, there are advanced tags, which are only being sent when Advanced Tags option is enabled in integration settings.

Default Tags

KeyDescription
ah_eventEvent Name
ah_status

Subscription Status. Possible Values:

trial, intro, regular, promo, refunded, expired, grace

JSON example of event with Default Tags:

{
    "ah_event": "apphud_subscription_renewed",
    "ah_product": "com.product.id"
}

Advanced Tags

If you enable Advanced Tags option in One Signal integration page, then additional tags will be sent:

KeyDescription
ah_spentTotal amount of money that user has been charged, in USD
ah_paymentsNumber of transactions user has been charged
ah_countryUser's App Store Country
ah_autorenewSubscription auto-renew state. "1" or "0"
ah_billing_issueWhether subscription has billing issue. "1" or "0"
ah_productProduct ID of the subscription

JSON example of event with Advanced Tags enabled:

{
    "ah_event": "apphud_subscription_renewed",
    "ah_product": "com.product.id",
    "ah_billing_issue": "0",
    "ah_autorenew": "1",
    "ah_country": "UK",
    "ah_status": "regular",
    "ah_spent": "9.99",
    "ah_payments": "1"
}

Using both OneSignal and Apphud Push Notifications on iOS

Make sure application:didReceiveRemoteNotification:userInfo: method is called.
Apphud SDK will return false if current push was not sent from Apphud.

func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
    let handled = Apphud.handlePushNotification(apsInfo: userInfo)
    if !handled {
        // this is not push from Apphud
    }
    completionHandler(.newData)
}