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 theApnsPushNotificationinterface.- Author:
- Jon Chambers
- See Also:
ApnsPayloadBuilder
-
-
Field Summary
Fields Modifier and Type Field Description static longDEFAULT_EXPIRATION_PERIOD_MILLISThe 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, String collapseId)Constructs a new push notification with the given token, topic, payload, delivery expiration time, delivery priority, and "collapse identifier."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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object obj)UUIDgetApnsId()Returns the canonical identifier for this push notification.StringgetCollapseId()Returns the "collapse ID" for this push notification, which allows it to supersede or be superseded by other notifications with the same ID.DategetExpiration()Returns the time at which this push notification is no longer valid and should no longer be delivered.StringgetPayload()Returns the payload to include in this push notification.DeliveryPrioritygetPriority()Returns the priority with which this push notification should be delivered to the receiving device.StringgetToken()Returns the token of the device to which this push notification should be delivered.StringgetTopic()Returns the topic to which this push notification should be sent.inthashCode()StringtoString()
-
-
-
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.- 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.- 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.- 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, String collapseId)
Constructs a new push notification with the given token, topic, payload, delivery expiration time, delivery priority, and "collapse identifier."- Parameters:
token- the device token to which this push notification should be delivered; must not benulltopic- the topic to which this notification should be sent; must not benullpayload- the payload to include in this push notification; must not benullinvalidationTime- 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 benulltopic- the topic to which this notification should be sent; must not benullpayload- the payload to include in this push notification; must not benullinvalidationTime- 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
-
-
Method Detail
-
getToken
public String getToken()
Returns the token of the device to which this push notification should be delivered.- Specified by:
getTokenin 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:
getPayloadin 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:
getExpirationin 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:
getPriorityin interfaceApnsPushNotification- Returns:
- the priority with which this push notification should be delivered to the receiving device
-
getTopic
public String getTopic()
Returns the topic to which this push notification should be sent.- Specified by:
getTopicin 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:
getCollapseIdin 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:
getApnsIdin interfaceApnsPushNotification- Returns:
- a unique identifier for this notification; may be
null, in which case the APNs server will assign an identifier automatically
-
-