LogoLogo
SDK ReferenceChangelogBlogStatusGet HelpGo To Dashboard
  • Introduction
  • Basics
    • How ContextDecision Works
    • How ContextPush Works
    • Getting Started
  • Context Decision
    • Logging Conversions
    • Revenue Outcomes
      • Logging Revenue with RevenueCat
    • Adding Entry Points
    • Release Checklist
    • Advanced
      • Custom Signals
      • Alternative Outcomes
      • Custom Outcome Metadata
      • Listening for Good Moments
      • Model Distribution Methods
      • Custom A/B Test Segmentation
      • Analytics & Reporting
  • Context Push
    • Integrating ContextPush
    • Push Notification Providers
      • OneSignal
      • Customer.io
      • Simple Web Request
    • Release Checklist
    • Analytics & Reporting
  • Discover By Use Cases
    • Multivariate Monetization
    • Inline Banners
  • Other Information
    • Glossary
    • Updating Your SDK
    • Minimum SDK Requirements
    • FAQ
    • Get Help
    • Changelog
  • Advanced
    • Custom Configuration
    • Capturing Context In Key Moments
Powered by GitBook
On this page
  • Integrating ContextSDK Push Notifications with OneSignal Journeys
  • Step 1: Add a Webhook Action to the Journey
  • Step 2: Set Up Request Headers
  • Step 3: Define the Request Body

Was this helpful?

  1. Context Push
  2. Push Notification Providers

OneSignal

Learn how to integrate ContextPush with OneSignal.

PreviousPush Notification ProvidersNextCustomer.io

Last updated 1 month ago

Was this helpful?

Integrating ContextSDK Push Notifications with OneSignal Journeys

This guide provides step-by-step instructions on how to configure to send push notifications using a webhook to interact with the ContextPush API.

Step 1: Add a Webhook Action to the Journey

  1. Go to the Journey you want to leverage context-aware push notifications.

  2. Add a new action within your journey by selecting "Add Action" and then choose "Send Webhook."

  3. Configure the webhook with the following details:

    • URL: https://push.contextsdk.com/v1/campaigns/schedule_message_for_user

    • Request Type: POST

Step 2: Set Up Request Headers

In the webhook configuration, include the necessary headers to authenticate the request:

  • Authorization: Bearer [Your_Token]

  • Content-Type: application/json

Step 3: Define the Request Body

Configure the webhook payload using OneSignal's templating to dynamically include user-specific data. Use the following JSON structure:

{
  "bundle_id": "com.contextsdk.demo",
  "platform": "ios",
  "user_id": "{{ user.external_id }}",
  "content": {
    "title": "It's time to get started with crypto",
    "body": "Just upload your ID, and start trading now"
  },
  "deliver_within_hours": 6,
  "campaign_id": "daily-reminder",
  "delivery_method": "context_aware"
}

Notes:

  • Replace {{ user.external_id }} with the appropriate OneSignal variable for the user ID.

  • Adjust the title and body fields to match your campaign's messaging.

Using the Key/Value Pairs Body

If you prefer configuring your payload purely through the OneSignal UI we have a special endpoint that is compatible with a non nested JSON body. Instead of https://push.contextsdk.com/v1/campaigns/schedule_message_for_user use the https://push.contextsdk.com/v1/campaigns/schedule_message_for_user_flattened endpoint. This allows you to replace all nested values with keys in the format of content/title, content/body, etc.

This way you can fully configure ContextPush using only Key/Value pairs.

{
  "bundle_id": "com.contextsdk.demo",
  "platform": "ios",
  "user_id": "{{ user.external_id }}",
  "content/title": "It's time to get started with crypto",
  "content/body": "Just upload your ID, and start trading now",
  "deliver_within_hours": 6,
  "campaign_id": "daily-reminder",
  "delivery_method": "context_aware"
}

Localization

You can use the built-in Liquid syntax to directly supply the localized string when scehduling a message. The below example uses the https://push.contextsdk.com/v1/campaigns/schedule_message_for_user_flattened endpoint:

{%- assign userLang = user.language -%}
{
  "bundle_id": "com.contextsdk.internal",
  "platform": "ios",
  "user_id": "{{ user.external_id }}",
  "content/default_locale": "en",
  "content/title/en": "{% if userLang == 'de' -%} James, es ist Zeit für deinen Englischkurs! {%- else -%} James, it's time for your english course! {%- endif %}",
  "content/body/en": "{% if userLang == 'de' -%} Starte jetzt mit deinem Kurs! {%- else -%} Start course now because its a good time! {%- endif %}",
  "deliver_within_hours": 3,
  "campaign_id": "daily-reminder",
  "delivery_method": "context_aware"
}
OneSignal's Journeys