use of org.openhab.ui.habot.notification.internal.webpush.Notification in project habot by ghys.
the class NotificationService method sendNotification.
/**
* Sends a web push notification to a specified subscription
*
* @param subscription the subscription to send the notification to
* @param payload the payload to push
* @return the {@link Future} for the {@link Response} to the push server
* @throws GeneralSecurityException
*/
public Future<Response> sendNotification(Subscription subscription, String payload) throws GeneralSecurityException {
getPushService();
Notification notification = new Notification(subscription, payload);
try {
return this.pushService.send(notification);
} catch (IOException | JoseException | ExecutionException | InterruptedException e) {
logger.error("Unable to send the notification to {}: {}", this.subscriptionProvider.keyToString(subscription.keys), e.toString());
return null;
}
}
Aggregations