Spring Boot Auto-Configuration
com.notificationhub.sdk.config.NotificationHubAutoConfiguration registers a NotificationHubClient bean automatically, conditioned on the presence of notificationhub.api-key and notificationhub.api-secret in your Spring configuration.
Properties
| Property | Required | Default |
|---|---|---|
notificationhub.api-key | ✅ | — |
notificationhub.api-secret | ✅ | — |
notificationhub.base-url | — | SDK production default |
application.yml
notificationhub:
api-key: ${NOTIFICATIONHUB_API_KEY}
api-secret: ${NOTIFICATIONHUB_API_SECRET}
Usage
Once the properties are set, inject NotificationHubClient like any other Spring bean — no manual Builder call needed:
@Service
public class OrderNotifier {
private final NotificationHubClient client;
public OrderNotifier(NotificationHubClient client) {
this.client = client;
}
public void notifyShipped(String email, String orderId) {
var request = NotificationRequest.builder()
.addChannel(ChannelType.EMAIL)
.toEmail(email)
.subject("Your order has shipped")
.message("Order " + orderId + " is on its way.")
.build();
client.notifications().send(request);
}
}
If either property is absent, the auto-configuration doesn't activate and no bean is registered — construct a NotificationHubClient manually with the Builder in that case, as shown in Configuration.