You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// The maximum encrypted payload size guaranteed by the spec.
28
31
///
@@ -57,18 +60,26 @@ public actor WebPushManager: Sendable {
57
60
/// - Note: On debug builds, this initializer will assert if VAPID authorization header expiration times are inconsistently set.
58
61
/// - Parameters:
59
62
/// - vapidConfiguration: The VAPID configuration to use when identifying the application server.
63
+
/// - networkConfiguration: The network configuration used when configuring the manager.
60
64
/// - backgroundActivityLogger: The logger to use for misconfiguration and background activity. By default, a print logger will be used, and if set to `nil`, a no-op logger will be used in release builds. When running in a server environment, your shared logger should be used instead giving you full control of logging and metadata.
61
65
/// - eventLoopGroupProvider: The event loop to use for the internal HTTP client.
62
66
publicinit(
63
67
vapidConfiguration:VAPID.Configuration,
64
-
// TODO: Add networkConfiguration for proxy, number of simultaneous pushes, etc…
/// Apple's push service recomments leaving the connection open as long as possible. We are picking 12 hours here.
81
+
/// - SeeAlso: [Sending notification requests to APNs: Follow best practices while sending push notifications with APNs](https://developer.apple.com/documentation/usernotifications/sending-notification-requests-to-apns#Follow-best-practices-while-sending-push-notifications-with-APNs)
@@ -125,6 +138,7 @@ public actor WebPushManager: Sendable {
125
138
precondition(!vapidConfiguration.keys.isEmpty,"VAPID.Configuration must have keys specified. Please report this as a bug with reproduction steps if encountered: https://github.com/mochidev/swift-webpush/issues.")
/// 429 too many requests, 500 internal server error, 503 server shutting down are all opportunities to just retry if we can, otherwise throw the error
680
-
guardletretryDuration=retryDurations.first else{
696
+
guardletretryInterval=retryIntervals.first else{
681
697
logger.trace("Message was rejected, no retries remaining.")
682
698
throwPushServiceError(response: response)
683
699
}
684
700
logger.trace("Message was rejected, but can be retried.")
685
701
686
-
tryawaitTask.sleep(for:retryDuration)
702
+
tryawaitTask.sleep(for:retryInterval)
687
703
tryawaitexecuteRequest(
688
704
httpClient: httpClient,
689
705
endpointURLString: endpointURLString,
@@ -694,7 +710,7 @@ public actor WebPushManager: Sendable {
/// A list of intervals to wait between automatic retries.
899
+
///
900
+
/// Only some push service errors can safely be automatically retried. When one such error is encountered, this list is used to wait a set amount of time after a compatible failure, then perform a retry, adjusting expiration values as needed.
901
+
///
902
+
/// Specify `[]` to disable retries.
903
+
publicvarretryIntervals:[Duration]
904
+
905
+
/// A flag to automatically generate a random `Topic` to prevent messages that are automatically retried from being delivered twice.
906
+
///
907
+
/// This is usually not necessary for a compliant push service, but can be turned on if you are experiencing the same message being delivered twice when a retry occurs.
908
+
publicvaralwaysResolveTopics:Bool
909
+
910
+
/// A timeout before a connection is dropped.
911
+
publicvarconnectionTimeout:Duration
912
+
913
+
/// A timeout before we abandon the connection due to messages not being sent.
914
+
///
915
+
/// If `nil`, no timeout will be used.
916
+
publicvarsendTimeout:Duration?
917
+
918
+
/// A timeout before we abondon the connection due to the push service not sending back acknowledgement a message was received.
919
+
///
920
+
/// If `nil`, no timeout will be used.
921
+
publicvarconfirmationTimeout:Duration?
922
+
923
+
/// An HTTP proxy to use when communicating to a push service.
/// - retryIntervals: A list of intervals to wait between automatic retries before giving up. Defaults to a maximum of three retries.
931
+
/// - alwaysResolveTopics: A flag to automatically generate a random `Topic` to prevent messages that are automatically retried from being delivered twice. Defaults to `false`.
932
+
/// - connectionTimeout: A timeout before a connection is dropped. Defaults to 10 seconds
933
+
/// - sendTimeout: A timeout before we abandon the connection due to messages not being sent. Defaults to no timeout.
934
+
/// - confirmationTimeout: A timeout before we abondon the connection due to the push service not sending back acknowledgement a message was received. Defaults to no timeout.
935
+
/// - httpProxy: An HTTP proxy to use when communicating to a push service. Defaults to no proxy.
0 commit comments