|
| 1 | +/* |
| 2 | + * Copyright (c) 2025 Jon Chambers |
| 3 | + * |
| 4 | + * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 5 | + * of this software and associated documentation files (the "Software"), to deal |
| 6 | + * in the Software without restriction, including without limitation the rights |
| 7 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 8 | + * copies of the Software, and to permit persons to whom the Software is |
| 9 | + * furnished to do so, subject to the following conditions: |
| 10 | + * |
| 11 | + * The above copyright notice and this permission notice shall be included in |
| 12 | + * all copies or substantial portions of the Software. |
| 13 | + * |
| 14 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 15 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 16 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 17 | + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 18 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 19 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 20 | + * THE SOFTWARE. |
| 21 | + */ |
| 22 | + |
| 23 | +package com.eatthepath.pushy.apns; |
| 24 | + |
| 25 | +import com.eatthepath.pushy.apns.util.ApnsPayloadBuilder; |
| 26 | + |
| 27 | +import java.time.Instant; |
| 28 | +import java.util.UUID; |
| 29 | + |
| 30 | +/** |
| 31 | + * <p>A broadcast push notification that can be sent through the Apple Push Notification service (APNs). Broadcast push |
| 32 | + * notifications are delivered to a channel, which may have multiple individual devices as subscribers.</p> |
| 33 | + * |
| 34 | + * @author <a href="https://github.com/jchambers">Jon Chambers</a> |
| 35 | + * |
| 36 | + * @see <a href="https://developer.apple.com/documentation/usernotifications/sending-broadcast-push-notification-requests-to-apns">Sending broadcast push notification requests to APNs</a> |
| 37 | + * |
| 38 | + * @see ApnsClient#createChannel(String, MessageStoragePolicy, UUID) |
| 39 | + * @see ApnsPayloadBuilder |
| 40 | + * |
| 41 | + * @since 0.16 |
| 42 | + */ |
| 43 | +public interface ApnsBroadcastPushNotification { |
| 44 | + |
| 45 | + /** |
| 46 | + * Returns the base64-encoded channel ID to which to publish this notification. |
| 47 | + * |
| 48 | + * @return the base64-encoded channel ID to which to publish this notification |
| 49 | + * |
| 50 | + * @see ApnsClient#createChannel(String, MessageStoragePolicy, UUID) |
| 51 | + */ |
| 52 | + String getChannelId(); |
| 53 | + |
| 54 | + /** |
| 55 | + * Returns the JSON-encoded payload for this push notification. |
| 56 | + * |
| 57 | + * @return the JSON-encoded payload for this push notification |
| 58 | + */ |
| 59 | + String getPayload(); |
| 60 | + |
| 61 | + /** |
| 62 | + * Returns the instant at which this notification expires. As the APNs documentation explains: |
| 63 | + * |
| 64 | + * <blockquote>If the value is nonzero, APNs stores the notification and attempts delivery at least once, repeating as |
| 65 | + * necessary until the specified date. If the value is 0, APNs attempts to deliver the notification only once and |
| 66 | + * doesn’t store it. Providing a nonzero expiration for a channel created with the No Message Stored storage policy |
| 67 | + * results in message rejection. |
| 68 | + * <p> |
| 69 | + * A single APNs attempt may involve retries over multiple network interfaces and connections of the destination |
| 70 | + * device. These retries often span some time period, depending on network characteristics. Additionally, a push |
| 71 | + * notification may take some time on the network after APNs sends it to the device. APNs makes best efforts to honor |
| 72 | + * the expiry date without any guarantee. If the value is nonzero, the notification may deliver after the specified |
| 73 | + * timestamp. If the value is 0, the notification may deliver with some delay.</blockquote> |
| 74 | + * |
| 75 | + * @return the instant at which the notification expires; may be {@code null}, in which case a value of 0 (i.e. |
| 76 | + * attempt delivery only once) is transmitted to the APNs server |
| 77 | + */ |
| 78 | + Instant getExpiration(); |
| 79 | + |
| 80 | + /** |
| 81 | + * Returns the priority with which this push notification should be sent to the receiving device. If {@code null}, |
| 82 | + * an immediate delivery priority is assumed. |
| 83 | + * |
| 84 | + * @return the priority with which this push notification should be sent to the receiving device |
| 85 | + */ |
| 86 | + DeliveryPriority getPriority(); |
| 87 | + |
| 88 | + /** |
| 89 | + * Returns the canonical identifier for this push notification. The APNs server will include the given identifier in |
| 90 | + * all responses related to this push notification. If no identifier is provided, the server will assign a unique |
| 91 | + * identifier automatically. |
| 92 | + * |
| 93 | + * @return a unique identifier for this notification; may be {@code null}, in which case the APNs server will assign |
| 94 | + * an identifier automatically |
| 95 | + */ |
| 96 | + UUID getApnsRequestId(); |
| 97 | +} |
0 commit comments