Package com.eatthepath.pushy.apns.util
Class SimpleApnsPushNotification
java.lang.Object
com.eatthepath.pushy.apns.util.SimpleApnsPushNotification
- All Implemented Interfaces:
ApnsPushNotification
A simple and immutable implementation of the
ApnsPushNotification
interface.- Author:
- Jon Chambers
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final Duration
The default expiration period for push notifications (one day). -
Constructor Summary
ConstructorDescriptionSimpleApnsPushNotification
(String token, String topic, String payload) Constructs a new push notification with the given token, topic, and payload.SimpleApnsPushNotification
(String token, String topic, String payload, Instant invalidationTime) Constructs a new push notification with the given token, topic, payload, and expiration time.SimpleApnsPushNotification
(String token, String topic, String payload, Instant invalidationTime, DeliveryPriority priority) Constructs a new push notification with the given token, topic, payload, delivery expiration time, and delivery priority.SimpleApnsPushNotification
(String token, String topic, String payload, Instant invalidationTime, DeliveryPriority priority, PushType pushType) Constructs a new push notification with the given token, topic, payload, delivery expiration time, delivery priority, and push notification type.SimpleApnsPushNotification
(String token, String topic, String payload, Instant invalidationTime, DeliveryPriority priority, PushType pushType, String collapseId) Constructs a new push notification with the given token, topic, payload, delivery expiration time, delivery priority, push notification type, and "collapse identifier."SimpleApnsPushNotification
(String token, String topic, String payload, Instant invalidationTime, DeliveryPriority priority, PushType pushType, String collapseId, UUID apnsId) Constructs a new push notification with the given token, topic, payload, delivery expiration time, delivery priority, "collapse identifier," and unique push notification identifier.SimpleApnsPushNotification
(String token, String topic, String payload, Instant invalidationTime, DeliveryPriority priority, String collapseId) Constructs a new push notification with the given token, topic, payload, delivery expiration time, delivery priority, and "collapse identifier." No push notification type is specified.SimpleApnsPushNotification
(String token, String topic, String payload, Instant invalidationTime, DeliveryPriority priority, String collapseId, UUID apnsId) Constructs a new push notification with the given token, topic, payload, delivery expiration time, delivery priority, "collapse identifier," and unique push notification identifier. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Returns the canonical identifier for this push notification.Returns the "collapse ID" for this push notification, which allows it to supersede or be superseded by other notifications with the same ID.Returns the time at which this push notification is no longer valid and should no longer be delivered.Returns the payload to include in this push notification.Returns the priority with which this push notification should be delivered to the receiving device.Returns the display type this push notification.getToken()
Returns the token of the device to which this push notification should be delivered.getTopic()
Returns the topic to which this push notification should be sent.int
hashCode()
toString()
-
Field Details
-
DEFAULT_EXPIRATION_PERIOD
The default expiration period for push notifications (one day).
-
-
Constructor Details
-
SimpleApnsPushNotification
Constructs a new push notification with the given token, topic, and payload. A default expiration time is set for the notification; callers that require immediate expiration or a non-default expiration period should use a constructor that accepts an expiration time as an argument. An "immediate" delivery priority is used for the notification, and as such the payload should contain an alert, sound, or badge component. No push notification type is specified.- Parameters:
token
- the device token to which this push notification should be deliveredtopic
- the topic to which this notification should be sentpayload
- the payload to include in this push notification- See Also:
-
SimpleApnsPushNotification
public SimpleApnsPushNotification(String token, String topic, String payload, Instant invalidationTime) Constructs a new push notification with the given token, topic, payload, and expiration time. An "immediate" delivery priority is used for the notification, and as such the payload should contain an alert, sound, or badge component. No push notification type is specified.- Parameters:
token
- the device token to which this push notification should be deliveredtopic
- the topic to which this notification should be sentpayload
- the payload to include in this push notificationinvalidationTime
- the time at which Apple's servers should stop trying to deliver this message; ifnull
, no delivery attempts beyond the first will be made- See Also:
-
SimpleApnsPushNotification
public SimpleApnsPushNotification(String token, String topic, String payload, Instant invalidationTime, DeliveryPriority priority) Constructs a new push notification with the given token, topic, payload, delivery expiration time, and delivery priority. No push notification type is specified.- Parameters:
token
- the device token to which this push notification should be deliveredtopic
- the topic to which this notification should be sentpayload
- the payload to include in this push notificationinvalidationTime
- the time at which Apple's servers should stop trying to deliver this message; ifnull
, no delivery attempts beyond the first will be madepriority
- the priority with which this notification should be delivered to the receiving device
-
SimpleApnsPushNotification
public SimpleApnsPushNotification(String token, String topic, String payload, Instant invalidationTime, DeliveryPriority priority, PushType pushType) Constructs a new push notification with the given token, topic, payload, delivery expiration time, delivery priority, and push notification type.- Parameters:
token
- the device token to which this push notification should be deliveredtopic
- the topic to which this notification should be sentpayload
- the payload to include in this push notificationinvalidationTime
- the time at which Apple's servers should stop trying to deliver this message; ifnull
, no delivery attempts beyond the first will be madepriority
- the priority with which this notification should be delivered to the receiving devicepushType
- the type of notification to be sent
-
SimpleApnsPushNotification
public SimpleApnsPushNotification(String token, String topic, String payload, Instant invalidationTime, DeliveryPriority priority, String collapseId) Constructs a new push notification with the given token, topic, payload, delivery expiration time, delivery priority, and "collapse identifier." No push notification type is specified.- Parameters:
token
- the device token to which this push notification should be delivered; must not benull
topic
- the topic to which this notification should be sent; must not benull
payload
- the payload to include in this push notification; must not benull
invalidationTime
- the time at which Apple's servers should stop trying to deliver this message; ifnull
, no delivery attempts beyond the first will be madepriority
- the priority with which this notification should be delivered to the receiving devicecollapseId
- the "collapse identifier" for this notification, which allows it to supersede or be superseded by other notifications with the same collapse identifier
-
SimpleApnsPushNotification
public SimpleApnsPushNotification(String token, String topic, String payload, Instant invalidationTime, DeliveryPriority priority, PushType pushType, String collapseId) Constructs a new push notification with the given token, topic, payload, delivery expiration time, delivery priority, push notification type, and "collapse identifier."- Parameters:
token
- the device token to which this push notification should be delivered; must not benull
topic
- the topic to which this notification should be sent; must not benull
payload
- the payload to include in this push notification; must not benull
invalidationTime
- the time at which Apple's servers should stop trying to deliver this message; ifnull
, no delivery attempts beyond the first will be madepriority
- the priority with which this notification should be delivered to the receiving devicepushType
- the type of notification to be sentcollapseId
- the "collapse identifier" for this notification, which allows it to supersede or be superseded by other notifications with the same collapse identifier
-
SimpleApnsPushNotification
public SimpleApnsPushNotification(String token, String topic, String payload, Instant invalidationTime, DeliveryPriority priority, String collapseId, UUID apnsId) Constructs a new push notification with the given token, topic, payload, delivery expiration time, delivery priority, "collapse identifier," and unique push notification identifier.- Parameters:
token
- the device token to which this push notification should be delivered; must not benull
topic
- the topic to which this notification should be sent; must not benull
payload
- the payload to include in this push notification; must not benull
invalidationTime
- the time at which Apple's servers should stop trying to deliver this message; ifnull
, no delivery attempts beyond the first will be madepriority
- the priority with which this notification should be delivered to the receiving devicecollapseId
- the "collapse identifier" for this notification, which allows it to supersede or be superseded by other notifications with the same collapse identifierapnsId
- the unique identifier for this notification; may benull
, in which case the APNs server will assign a unique identifier automatically
-
SimpleApnsPushNotification
public SimpleApnsPushNotification(String token, String topic, String payload, Instant invalidationTime, DeliveryPriority priority, PushType pushType, String collapseId, UUID apnsId) Constructs a new push notification with the given token, topic, payload, delivery expiration time, delivery priority, "collapse identifier," and unique push notification identifier.- Parameters:
token
- the device token to which this push notification should be delivered; must not benull
topic
- the topic to which this notification should be sent; must not benull
payload
- the payload to include in this push notification; must not benull
invalidationTime
- the time at which Apple's servers should stop trying to deliver this message; ifnull
, no delivery attempts beyond the first will be madepriority
- the priority with which this notification should be delivered to the receiving devicepushType
- the type of push notification to be deliveredcollapseId
- the "collapse identifier" for this notification, which allows it to supersede or be superseded by other notifications with the same collapse identifierapnsId
- the unique identifier for this notification; may benull
, in which case the APNs server will assign a unique identifier automatically
-
-
Method Details
-
getToken
Returns the token of the device to which this push notification should be delivered.- Specified by:
getToken
in interfaceApnsPushNotification
- Returns:
- the token of the device to which this push notification should be delivered
-
getPayload
Returns the payload to include in this push notification.- Specified by:
getPayload
in interfaceApnsPushNotification
- Returns:
- the payload to include in this push notification
-
getExpiration
Returns the time at which this push notification is no longer valid and should no longer be delivered.- Specified by:
getExpiration
in interfaceApnsPushNotification
- Returns:
- the time at which this push notification is no longer valid and should no longer be delivered
-
getPriority
Returns the priority with which this push notification should be delivered to the receiving device.- Specified by:
getPriority
in interfaceApnsPushNotification
- Returns:
- the priority with which this push notification should be delivered to the receiving device
-
getPushType
Returns the display type this push notification. Note that push notification display types are required in iOS 13 and later and watchOS 6 and later, but are ignored under earlier versions of either operating system. May benull
.- Specified by:
getPushType
in interfaceApnsPushNotification
- Returns:
- the display type this push notification
- Since:
- 0.13.9
-
getTopic
Returns the topic to which this push notification should be sent.- Specified by:
getTopic
in interfaceApnsPushNotification
- Returns:
- the topic to which this push notification should be sent
-
getCollapseId
Returns the "collapse ID" for this push notification, which allows it to supersede or be superseded by other notifications with the same ID.- Specified by:
getCollapseId
in interfaceApnsPushNotification
- Returns:
- the "collapse ID" for this push notification
-
getApnsId
Returns the canonical identifier for this push notification. The APNs server will include the given identifier in all responses related to this push notification. If no identifier is provided, the server will assign a unique identifier automatically.- Specified by:
getApnsId
in interfaceApnsPushNotification
- Returns:
- a unique identifier for this notification; may be
null
, in which case the APNs server will assign an identifier automatically
-
equals
-
hashCode
public int hashCode() -
toString
-