Skip to main content

Notifizz Java SDK

The notifizz-java SDK is the official Notifizz client for Java and Kotlin. It is published to Maven Central. Use it to track events, run workflows, generate hashed user tokens, and send notifications to the Notification Center.

Installation

Add the dependency to your project. No custom repository or credentials are required; Maven Central is used by default.

Maven

<dependency>
    <groupId>com.notifizz</groupId>
    <artifactId>notifizz-java</artifactId>
    <version>1.0.0</version>
</dependency>

Gradle (Groovy)

dependencies {
    implementation "com.notifizz:notifizz-java:1.0.0"
}

Gradle (Kotlin DSL)

dependencies {
    implementation("com.notifizz:notifizz-java:1.0.0")
}

Initialize the client

import com.notifizz.NotifizzClient;
import com.notifizz.TrackContext;
import java.util.*;

NotifizzClient client = new NotifizzClient("your-auth-secret", "your-sdk-secret");

Track events with workflows

Call track() with a map containing eventName, sdkSecretKey, and properties. Then attach workflows and recipients, and call send() on the context:
Map<String, Object> props = new HashMap<>();
props.put("eventName", "user_signed_up");
props.put("sdkSecretKey", "your-sdk-secret");
props.put("properties", Map.of(
    "plan", "pro",
    "source", "landing_page"
));

List<Map<String, Object>> recipients = List.of(
    Map.of("id", "user_1", "email", "user1@example.com"),
    Map.of("id", "user_2", "email", "user2@example.com")
);

TrackContext context = client.track(props);
context.workflow("campaign_123", recipients);
context.send();
You can chain multiple .workflow(campaignId, recipients) calls before calling send().

Generate a hashed user token

Use this for backend authentication (e.g. when the Notification Center is authenticated with a backend token):
String token = client.generateHashedToken("user_123");

Send a notification to the Notification Center

Map<String, Object> request = new HashMap<>();
request.put("notifId", "notif_123");

Map<String, Object> properties = new HashMap<>();
properties.put("recipients", List.of(
    Map.of("id", "user_1", "email", "user@example.com")
));
properties.put("message", "Hello world");
request.put("properties", properties);

Map<String, Object> response = client.send(request);

Configuration

Configure client options such as the auto-send delay (in milliseconds) for tracked events:
client.config(Map.of("autoSendDelayMs", 2000));

API summary

MethodDescription
new NotifizzClient(authSecretKey, sdkSecretKey)Create a client.
client.track(props)Start tracking an event; props contains eventName, sdkSecretKey, properties. Returns a TrackContext.
context.workflow(campaignId, recipients)Attach a workflow and recipients (chainable).
context.send()Send the tracked event (call after adding workflows).
client.generateHashedToken(userId)Generate a hashed token for the user.
client.send(request)Send a notification to the Notification Center. request has notifId and properties (including recipients).
client.config(opts)Configure options (e.g. autoSendDelayMs).