Package com.iizix.push
Class PushServer
java.lang.Object
com.iizix.push.PushServer
Push server for VAPID, Firebase and APNS messages.
- Author:
- Christopher Mindus
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intDefault Time-to-Live for Notifications in milliseconds: 24 days, extremely long time!Constructor Summary
ConstructorsConstructorDescriptionPushServer(ExecutorService executorService, String vapidPublicKey, String vapidPrivateKey, String gcmApiKey, String subject) Constructs the push server.Method Summary
Modifier and TypeMethodDescriptioncreateNotification(IPushSubscription subscription, String payloadMessage, int ttl, PushUrgency urgency, String topic) Constructs a new notification instance for use with browsers and non-Apple devices.createSubscription(String endPoint, String p256dh, String auth) Gets the subscription for a client used to later send a push notification.voidpush(com.iizix.push.PushNotification notification) Adds a push notification to be sent to the client.
Field Details
DEFAULT_TTL
public static final int DEFAULT_TTLDefault Time-to-Live for Notifications in milliseconds: 24 days, extremely long time!- See Also:
Constructor Details
PushServer
public PushServer(ExecutorService executorService, String vapidPublicKey, String vapidPrivateKey, String gcmApiKey, String subject) throws GeneralSecurityException Constructs the push server.- Parameters:
executorService- The executor service handling multi-threading depending on the CPU config and queued requests.vapidPublicKey- The VAPIC public key.vapidPrivateKey- The VAPIC private key.gcmApiKey- Google Cloud Messaging API key, ornull for none.subject- The subject.- Throws:
NullPointerException- IfexecutorService,vapidPublicKey,vapidPrivateKeyorsubjectisnull.GeneralSecurityException- General security exception in case of errors.
Method Details
createNotification
public IPushNotification createNotification(IPushSubscription subscription, String payloadMessage, int ttl, PushUrgency urgency, String topic) Constructs a new notification instance for use with browsers and non-Apple devices.- Parameters:
subscription- The subscription.payloadMessage- The payload message as plain text.ttl- The Time-to-Live in milliseconds of the message, zero or less for default 28 days = (2_419_200_000 milliseconds).urgency- The urgency of the notification.topic- The topic of the notification.- Returns:
- A new notification instance.
- Throws:
NullPointerException- Ifsubscription,payloadMessageorurgencyisnull.
createSubscription
Gets the subscription for a client used to later send a push notification. The subscription can be stored in the IClientSessionGyro as it doesn't change for the client session.- Parameters:
endPoint- The end point URL String.p256dh- The key encoded as a Base64 String.auth- The authentication encoded as a Base64 String.- Returns:
- The subscription for the client.
- Throws:
NullPointerException- If theendPointisnull.IllegalArgumentException- Ifp256dhorauthis not in valid Base64 scheme or invalidp256dhkey encoding.
push
public void push(com.iizix.push.PushNotification notification) Adds a push notification to be sent to the client. The notification will be done by the executor service as soon as possible.- Parameters:
notification- The notification to be sent.