Azure Notification Hubs SDK for Java
This is the v1.0.5 release of the Azure Notification Hubs SDK for Java. This contains the following:
Changelist
This is the v1.0.4 release of the Azure Notification Hubs SDK for Java. This contains the following:
Changelist
This is the v1.0.3 release of the Azure Notification Hubs SDK for Java. This contains the following:
Bug Fixes
inputFireUri
in the NotificationHubJob
in a CNAME
for URI escapingThis is the 1.0.0 release of the Azure Notification Hubs SDK for Java.
This release adds the following:
AdmNotification
AppleNotification
BaiduNotification
FcmNotification
MpnsNotification
WindowsNotification
WindowsRawNotification
BaseInstallation
AdmInstallation
AppleInstallation
BaiduInstallation
FcmInstallation
MpnsInstallation
WindowsInstallation
Misc stuff fixed:
equals
and hashcode
implementations based upon IntelliJ recommendationsSasTokenProvider
This update is a minor update to create the sources.jar and javadoc.jar files for MavenCentral and SonaType.
Update junit to deal with CVE https://github.com/advisories/GHSA-269g-pwp5-87pp
This update includes a number of new features with the following:
With the Installation API we now have a new feature that allows you to associate a user ID with an installation and then be able to target it with a send to all devices for that user. To set the user ID for the installation, set the UserId
property of the Installation
.
Installation installation = new Installation();
installation.setUserId("user1234");
hub.createOrUpdateInstallation(installation);
The user can then be targeted to send a notification with the tag format of $UserId:{USER_ID}
, for example like the following:
String jsonPayload = "{\"aps\":{\"alert\":\"Notification Hub test notification\"}}";
Set<String> tags = new HashSet<String>();
tags.add("$UserId:user1234");
Notification n = Notification.createAppleNotification(jsonPayload);
NotificationOutcome outcome = hub.sendNotification(n, tags);
By default, the Azure Notification Hubs SDK for Java by default does not have any retry behavior. You can add this behavior to the SDK by introducing libraries such as Failsafe or reactive libraries such as RxJava or Reactor.
The SDK will throw a NotificationHubsException
if there is anything but a successful HTTP operation such as 200 (OK), 201 (Created) or 204 (No Content). The NotificationHubsException
class has two properties worth noting, isTransient
to determine whether the failure is transient, and retryAfter
which gives the value from the Retry-After
header which indicates after how many seconds to retry the operation.
The following HTTP status codes can be retried for the SDK:
The following HTTP status codes should not be retried: 400 (Bad Request), 401 (Unauthorized), 404 (Not Found), 405 (Method Not Allowed) , 409 (Conflict), 410 (Gone), 412 (Precondition Failed), 413 (Request Entity Too Large).
// Create an execution policy
RetryPolicy<Installation> retryPolicy = new RetryPolicy<>()
.handle(NotificationHubsException.class)
.handleIf(error -> {
NotificationHubsException ex = (NotificationHubsException)err;
return ex.isTransient();
})
.withDelay(Duration.ofSeconds(5))
.withMaxRetries(3);
// Initialize installation
Installation installation = new Installation("installation-id", NotificationPlatform.Adm, "adm-push-channel");
// Run the operation with a static delay
Installation createdInstallation =
Failsafe.with(retryPolicy)
.get(() -> hub.createOrUpdateInstallation(installation));
The Azure Notification Hubs SDK has support for Firebase Cloud Messaging (FCM) via the Legacy HTTP API which is compatible with GCM. For registrations, use the FirebaseRegistration
to create registrations, as the GcmRegistration
class has been deprecated. For more information, read the Azure Notification Hubs and Google Firebase Cloud Messaging migration
For installations, use the NotificationPlatform.Gcm
for all FCM registrations which use the legacy HTTP API. Currently, we do not have full support for FCM and calling NotificationPlatform.Fcm
will result in an exception.
Installation i = new Installation();
// Uses the FCM Legacy API
i.setPlatform(NotificationPlatform.Gcm);
This SDK release contains minor updates to the following dependencies: