Package com.turo.pushy.apns.util
Class SimpleApnsPushNotification
- java.lang.Object
-
- com.turo.pushy.apns.util.SimpleApnsPushNotification
-
- All Implemented Interfaces:
ApnsPushNotification
public class SimpleApnsPushNotification extends Object implements ApnsPushNotification
A simple and immutable implementation of theApnsPushNotification
interface.- Author:
- Jon Chambers
- See Also:
ApnsPayloadBuilder
-
-
Field Summary
Fields Modifier and Type Field Description static long
DEFAULT_EXPIRATION_PERIOD_MILLIS
The default expiration period for push notifications (one day).
-
Constructor Summary
Constructors Constructor Description SimpleApnsPushNotification(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, Date invalidationTime)
Constructs a new push notification with the given token, topic, payload, and expiration time.SimpleApnsPushNotification(String token, String topic, String payload, Date 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, Date 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, Date 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, Date 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, Date 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, Date 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 Type Method Description boolean
equals(Object obj)
UUID
getApnsId()
Returns the canonical identifier for this push notification.String
getCollapseId()
Returns the "collapse ID" for this push notification, which allows it to supersede or be superseded by other notifications with the same ID.Date
getExpiration()
Returns the time at which this push notification is no longer valid and should no longer be delivered.String
getPayload()
Returns the payload to include in this push notification.DeliveryPriority
getPriority()
Returns the priority with which this push notification should be delivered to the receiving device.PushType
getPushType()
Returns the display type this push notification.String
getToken()
Returns the token of the device to which this push notification should be delivered.String
getTopic()
Returns the topic to which this push notification should be sent.int
hashCode()
String
toString()
-
-
-
Constructor Detail
-
SimpleApnsPushNotification
public SimpleApnsPushNotification(String token, String topic, String payload)
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:
DeliveryPriority.IMMEDIATE
,DEFAULT_EXPIRATION_PERIOD_MILLIS
-
SimpleApnsPushNotification
public SimpleApnsPushNotification(String token, String topic, String payload, Date 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:
DeliveryPriority.IMMEDIATE
-
SimpleApnsPushNotification
public SimpleApnsPushNotification(String token, String topic, String payload, Date 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, Date 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 madepushType
- the type of notification to be sentpriority
- the priority with which this notification should be delivered to the receiving device
-
SimpleApnsPushNotification
public SimpleApnsPushNotification(String token, String topic, String payload, Date 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, Date 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 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, Date 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, Date 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 Detail
-
getToken
public String 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
public String 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
public Date 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
public DeliveryPriority 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
public PushType 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
public String 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
public String 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
public UUID 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
-
-