Class NotificationSDKServer
java.lang.Object
com.vasco.digipass.sdk.utils.notification.server.NotificationSDKServer
Provides the entry points for the NotificationSDKServer library:
NotificationSDKServer(NotificationSDKServerCredentials, NotificationSDKServerSettings, NotificationSDKServerCallbacks)
: contructs the server object;sendNotification(String, Notification)
: sends a notification to a specific user device;awaitSendTerminationAndFinish()
: closes remaining tasks according to the object's settings and eventually closes existing connections;getPayloadLength(Notification, NotificationSDKServerPlatformNames)
: gets the payload length for a specific notification and platform;getPlatformName(String)
: gets the platform name of a specific user device (NotificationSDKServerPlatformNames
).
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
Maximum length, in bytes, of the notification payload for Android as described by the Google Cloud Messaging (GCM) specifications.static final int
Maximum length, in bytes, of the notification payload for iOS as described by the Apple Push Notification Service (APNS) specifications.static final String
NotificationSDKServer library version -
Constructor Summary
ConstructorsConstructorDescriptionNotificationSDKServer
(NotificationSDKServerCredentials credentials, NotificationSDKServerSettings settings, NotificationSDKServerCallbacks callbacks) Constructs a NotificationSDKServer object. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Wait for all submitted notifications to be sent.void
Wait for all submitted notifications to be sent.static int
getPayloadLength
(Notification notification, NotificationSDKServerPlatformNames platformName) Gets the notification payload length, in bytes, depending on the given platform name.getPlatformName
(String vascoNotificationIdentifier) Gets the platform name from a VASCONotificationIdentifier identified by its hexadecimal representation.void
sendNotification
(String vascoNotificationIdentifier, Notification notification) Sends a notification, described by a Notification object, using the specified client device identifier.
-
Field Details
-
VERSION
NotificationSDKServer library version- See Also:
-
MAX_PAYLOAD_LENGTH_ANDROID
public static final int MAX_PAYLOAD_LENGTH_ANDROIDMaximum length, in bytes, of the notification payload for Android as described by the Google Cloud Messaging (GCM) specifications. This constant's value is 4096.- See Also:
-
MAX_PAYLOAD_LENGTH_IOS
public static final int MAX_PAYLOAD_LENGTH_IOSMaximum length, in bytes, of the notification payload for iOS as described by the Apple Push Notification Service (APNS) specifications. This constant's value is 4096.- See Also:
-
-
Constructor Details
-
NotificationSDKServer
public NotificationSDKServer(NotificationSDKServerCredentials credentials, NotificationSDKServerSettings settings, NotificationSDKServerCallbacks callbacks) throws NotificationSDKServerException Constructs a NotificationSDKServer object.- Parameters:
credentials
- TheNotificationSDKServerCredentials
necessary to log in to the platform specific push notification services.settings
- TheNotificationSDKServerSettings
necessary to tune server specific settings. Can be null.callbacks
- TheNotificationSDKServerCallbacks
necessary to get feedback from the server in case of success/failure of the sending process. Can be null.- Throws:
NotificationSDKServerException
- Exception containing an error code and a message. Available error codes are:NotificationSDKServerErrorCodes.SETTINGS_INVALID
if the notification settings is invalid.
-
-
Method Details
-
getPlatformName
public static NotificationSDKServerPlatformNames getPlatformName(String vascoNotificationIdentifier) throws NotificationSDKServerException Gets the platform name from a VASCONotificationIdentifier identified by its hexadecimal representation.- Parameters:
vascoNotificationIdentifier
- Hexadecimal representation of the VASCO notification identifier.- Returns:
- the platform name of VASCONotificationIdentifier (see
NotificationSDKServerPlatformNames
). - Throws:
NotificationSDKServerException
- Exception containing an error code and a message. Available error codes are:NotificationSDKServerErrorCodes.INTERNAL_ERROR
if an internal error occurs.NotificationSDKServerErrorCodes.VASCO_NOTIFICATION_IDENTIFIER_NULL
if the identifier is null or empty.NotificationSDKServerErrorCodes.VASCO_NOTIFICATION_IDENTIFIER_INCORRECT_FORMAT
if the identifier has a wrong format (must be hexadecimal).NotificationSDKServerErrorCodes.VASCO_NOTIFICATION_IDENTIFIER_INVALID
if the identifier is invalid.
-
getPayloadLength
public static int getPayloadLength(Notification notification, NotificationSDKServerPlatformNames platformName) throws NotificationSDKServerException Gets the notification payload length, in bytes, depending on the given platform name. For all platforms, the payload is encoded in UTF-8 before its length calculation. Therefore, a non-latin character (Cyrillic, Japanese, Arabic, etc.) will have a length greater than 1. Please note that each protocol adds some overhead. The usable length is thus smaller than the theoretical maximum payload length.- Parameters:
notification
- notification containing a title, subject...platformName
- targeted platform name- Returns:
- The notification payload length in bytes.
- Throws:
NotificationSDKServerException
- Exception containing an error code and a message. Available error codes are:NotificationSDKServerErrorCodes.NOTIFICATION_NULL
if the notification settings is null.NotificationSDKServerErrorCodes.NOTIFICATION_TITLE_NULL
if the notification title is null.NotificationSDKServerErrorCodes.NOTIFICATION_IOS_TITLE_CHARACTER_INVALID
if the notification title contains an invalid character and the notification must be send to an iOS platform.NotificationSDKServerErrorCodes.NOTIFICATION_SUBJECT_NULL
if the notification subject is null.NotificationSDKServerErrorCodes.NOTIFICATION_CONTENT_NULL
if the notification content is null.
-
sendNotification
public void sendNotification(String vascoNotificationIdentifier, Notification notification) throws NotificationSDKServerException Sends a notification, described by a Notification object, using the specified client device identifier.As the process of sending a notification is asynchronous, a callback is necessary in order to handle errors or to report success.
- Parameters:
vascoNotificationIdentifier
- VASCO notification identifier provided by the client. String, cannot be null or empty.notification
- Notification that must be sent to the device (checkNotification
).- Throws:
NotificationSDKServerException
- Exception containing an error code and a message. Available error codes are:NotificationSDKServerErrorCodes.INTERNAL_ERROR
if an internal error occurred.NotificationSDKServerErrorCodes.CALL_ON_TERMINATED_INSTANCE
if the object instance has been finished prior to the call.NotificationSDKServerErrorCodes.VASCO_NOTIFICATION_IDENTIFIER_NULL
if the notification identifier is null.NotificationSDKServerErrorCodes.VASCO_NOTIFICATION_IDENTIFIER_INCORRECT_FORMAT
if the identifier has a wrong format (must be hexadecimal).NotificationSDKServerErrorCodes.VASCO_NOTIFICATION_IDENTIFIER_INVALID
if the notification identifier is invalid.NotificationSDKServerErrorCodes.CREDENTIALS_NULL
if the credentials object is null.NotificationSDKServerErrorCodes.CREDENTIALS_ANDROID_INVALID
if the Android part of the credentials object is invalid.NotificationSDKServerErrorCodes.CREDENTIALS_IOS_INVALID
if the iOS part of the credentials object is invalid.NotificationSDKServerErrorCodes.NOTIFICATION_NULL
if the notification settings is null.NotificationSDKServerErrorCodes.NOTIFICATION_TITLE_NULL
if the notification title is null.NotificationSDKServerErrorCodes.NOTIFICATION_IOS_TITLE_CHARACTER_INVALID
if the notification title contains an invalid character and the notification must be send to an iOS platform.NotificationSDKServerErrorCodes.NOTIFICATION_IOS_NO_APP_BUNDLE_ID
if no application bundle ID has been set.NotificationSDKServerErrorCodes.NOTIFICATION_SUBJECT_NULL
if the notification subject is null.NotificationSDKServerErrorCodes.NOTIFICATION_CONTENT_NULL
if the notification content is null.NotificationSDKServerErrorCodes.NOTIFICATION_ANDROID_DATA_TOO_LONG
if the Android data of the notification is too long.NotificationSDKServerErrorCodes.NOTIFICATION_IOS_DATA_TOO_LONG
if the iOS data of the notification is too long.NotificationSDKServerErrorCodes.NOTIFICATION_PROVIDER_ANDROID_ERROR
if there has been an error with the Google notification service provider.NotificationSDKServerErrorCodes.NOTIFICATION_PROVIDER_IOS_ERROR
if there has been an error with the Apple notification service provider.
-
awaitSendTermination
Wait for all submitted notifications to be sent.The last notifications that have not been sent after a specific timeout (which is specified in the
NotificationSDKServerSettings
object of the NotificationSDKServer object) will be cancelled.All connections are restarted.
- Throws:
InterruptedException
- if the thread has been interrupted while waiting for the termination of the existing tasks.NotificationSDKServerException
- Exception containing an error code and a message. Available error codes are:NotificationSDKServerErrorCodes.CALL_ON_TERMINATED_INSTANCE
if the object instance has been finished prior to the call.
-
awaitSendTerminationAndFinish
public void awaitSendTerminationAndFinish() throws InterruptedException, NotificationSDKServerExceptionWait for all submitted notifications to be sent.The last notifications that have not been sent after a specific timeout (which is specified in the
NotificationSDKServerSettings
object of the NotificationSDKServer object) will be cancelled.All connections are closed. The object is not usable anymore and thus can't be used to send notifications.
- Throws:
InterruptedException
- if the thread has been interrupted while waiting for the termination of the existing tasks.NotificationSDKServerException
- Exception containing an error code and a message. Available error codes are:NotificationSDKServerErrorCodes.CALL_ON_TERMINATED_INSTANCE
if the object instance has been finished prior to the call.
-