Class SimpleApnsPushNotification

java.lang.Object
com.eatthepath.pushy.apns.util.SimpleApnsPushNotification
All Implemented Interfaces:
ApnsPushNotification

public class SimpleApnsPushNotification extends Object implements ApnsPushNotification
A simple and immutable implementation of the ApnsPushNotification interface.
Author:
Jon Chambers
See Also:
  • Field Details

    • DEFAULT_EXPIRATION_PERIOD

      public static final Duration DEFAULT_EXPIRATION_PERIOD
      The default expiration period for push notifications (one day).
  • Constructor Details

    • 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 delivered
      topic - the topic to which this notification should be sent
      payload - 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 delivered
      topic - the topic to which this notification should be sent
      payload - the payload to include in this push notification
      invalidationTime - the time at which Apple's servers should stop trying to deliver this message; if null, 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 delivered
      topic - the topic to which this notification should be sent
      payload - the payload to include in this push notification
      invalidationTime - the time at which Apple's servers should stop trying to deliver this message; if null, no delivery attempts beyond the first will be made
      priority - 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 delivered
      topic - the topic to which this notification should be sent
      payload - the payload to include in this push notification
      invalidationTime - the time at which Apple's servers should stop trying to deliver this message; if null, no delivery attempts beyond the first will be made
      priority - the priority with which this notification should be delivered to the receiving device
      pushType - 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 be null
      topic - the topic to which this notification should be sent; must not be null
      payload - the payload to include in this push notification; must not be null
      invalidationTime - the time at which Apple's servers should stop trying to deliver this message; if null, no delivery attempts beyond the first will be made
      priority - the priority with which this notification should be delivered to the receiving device
      collapseId - 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 be null
      topic - the topic to which this notification should be sent; must not be null
      payload - the payload to include in this push notification; must not be null
      invalidationTime - the time at which Apple's servers should stop trying to deliver this message; if null, no delivery attempts beyond the first will be made
      priority - the priority with which this notification should be delivered to the receiving device
      pushType - the type of notification to be sent
      collapseId - 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 be null
      topic - the topic to which this notification should be sent; must not be null
      payload - the payload to include in this push notification; must not be null
      invalidationTime - the time at which Apple's servers should stop trying to deliver this message; if null, no delivery attempts beyond the first will be made
      priority - the priority with which this notification should be delivered to the receiving device
      collapseId - the "collapse identifier" for this notification, which allows it to supersede or be superseded by other notifications with the same collapse identifier
      apnsId - the unique identifier for this notification; may be null, 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 be null
      topic - the topic to which this notification should be sent; must not be null
      payload - the payload to include in this push notification; must not be null
      invalidationTime - the time at which Apple's servers should stop trying to deliver this message; if null, no delivery attempts beyond the first will be made
      priority - the priority with which this notification should be delivered to the receiving device
      pushType - the type of push notification to be delivered
      collapseId - the "collapse identifier" for this notification, which allows it to supersede or be superseded by other notifications with the same collapse identifier
      apnsId - the unique identifier for this notification; may be null, in which case the APNs server will assign a unique identifier automatically
  • Method Details

    • getToken

      public String getToken()
      Returns the token of the device to which this push notification should be delivered.
      Specified by:
      getToken in interface ApnsPushNotification
      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 interface ApnsPushNotification
      Returns:
      the payload to include in this push notification
    • getExpiration

      public Instant getExpiration()
      Returns the time at which this push notification is no longer valid and should no longer be delivered.
      Specified by:
      getExpiration in interface ApnsPushNotification
      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 interface ApnsPushNotification
      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 be null.
      Specified by:
      getPushType in interface ApnsPushNotification
      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 interface ApnsPushNotification
      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 interface ApnsPushNotification
      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 interface ApnsPushNotification
      Returns:
      a unique identifier for this notification; may be null, in which case the APNs server will assign an identifier automatically
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object