Installation
Understand more regarding core messaging concepts at Apps > Messaging
Understand more regarding messaging at Apps > Messaging
- JavaScript
- iOS
- Android
- Node.js
- Spring Boot (Java)
- Python
- Ruby
If you're using npm:
npm install @dashx/browser
If you're using yarn:
yarn add @dashx/browser
Configure the DashX client as early as possible in your application:
import DashX from '@dashx/browser'
DashX.configure({
publicKey: '<YOUR PUBLIC KEY>', // required
baseUri: '<YOUR BASE URI>', // optional
targetEnvironment: '<YOUR ENVIRONMENT>' // optional
})
The minimum supported version for iOS is 13.0. To set the Minimum SDK target:
- Open your iOS project in Xcode
- Select your Target > General > Deployment Info > Ensure that the version is set to 13.0+
Using Swift Package Manager (recommended)
- In your Xcode project, go to File > Add Package Dependencies…
- Paste the following URL in "Search or Enter Package URL":
https://github.com/dashxhq/dashx-ios.git
- Add the DashX library to your app target. If you use push notifications / Firebase integration helpers from this SDK, also add DashXFirebase.
Using CocoaPods
The published DashX pod includes the core SDK only. The DashXFirebase helper (e.g. DashXAppDelegate) is not distributed as a separate CocoaPod — add the Swift package for that, or follow the iOS SDK push setup.
- Update your Podfile:
platform :ios, '13.0' # must be 13 or higher
# ...
target 'YOUR_TARGET_NAME' do
# ...
pod 'DashX'
# ...
end
- Open Terminal in your project's root directory and run:
pod install
- Add Maven Central repository to your settings.gradle file:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
// ...
google()
mavenCentral()
}
}
- Add
dashx-androidas a dependency in your module-level build.gradle file:
dependencies {
// ...
implementation 'com.dashx:dashx-android:1.2.4'
}
- Ensure you're using Java 11 or higher (Java 11 is the minimum).
android {
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
}
If you're using Android Studio, you should hit the Sync Now button that pops up after modifying build.gradle.
DashX needs to be initialized as early as possible in your application's lifecycle, which is generally in an instance of the Android Application class:
import android.app.Application
import com.dashx.android.DashX
class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
DashX.configure(
context = this,
publicKey = "...", // required
baseURI = null, // optional (defaults to https://api.dashx.com/graphql)
targetEnvironment = null, // optional
)
}
}
If your product uses multiple environments, a good practice is to:
- create
productFlavorsfor each environment, - use
buildConfigFieldto declare your DashX configuration, and then - use
BuildConfigto pass your configuration as parameters.
If you're using npm:
npm install @dashx/node
If you're using yarn:
yarn add @dashx/node
const DashX = require('@dashx/node');
// Initialize DashX SDK
const dx = DashX.createClient({
publicKey: process.env.DASHX_PUBLIC_KEY,
privateKey: process.env.DASHX_PRIVATE_KEY,
});
The SDK can also be initialized with no parameters, dashx-node will then look for these env variables DASHX_PUBLIC_KEY and DASHX_PRIVATE_KEY.
const DashX = require('@dashx/node');
// Initialize DashX SDK
const dx = DashX.createClient();
Add the dependency to your project:
Gradle:
dependencies {
implementation 'com.dashx:dashx-spring-boot-starter:1.4.1'
}
Maven:
<dependency>
<groupId>com.dashx</groupId>
<artifactId>dashx-spring-boot-starter</artifactId>
<version>1.4.1</version>
</dependency>
Configure the SDK in your application.properties:
dashx.public-key=${DASHX_PUBLIC_KEY}
dashx.private-key=${DASHX_PRIVATE_KEY}
dashx.target-environment=${DASHX_TARGET_ENVIRONMENT}
The DashX bean is then auto-configured and can be injected anywhere in your application:
import com.dashx.DashX;
import org.springframework.stereotype.Service;
@Service
public class MyService {
private final DashX dashX;
public MyService(DashX dashX) {
this.dashX = dashX;
}
}
pip install dashx
Add this line to your application's Gemfile:
gem 'dashx'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install dashx
require 'dashx'
# Initialize DashX SDK
DashX.configure do |config|
config.public_key = ENV['DASHX_PUBLIC_KEY']
config.private_key = ENV['DASHX_PRIVATE_KEY']
end