Skip to content

Remove expiration and priority from widgets #221

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Sources/APNSCore/Widgets/APNSClient+Widgets.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ extension APNSClientProtocol {
message: notification,
deviceToken: deviceToken,
pushType: .widgets,
expiration: notification.expiration,
priority: notification.priority,
expiration: nil,
priority: nil,
apnsID: notification.apnsID,
topic: notification.topic,
collapseID: nil
Expand Down
22 changes: 0 additions & 22 deletions Sources/APNSCore/Widgets/APNSWidgetsNotification.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,33 +45,17 @@ public struct APNSWidgetsNotification: APNSMessage {
/// The topic for the notification. In general, the topic is your app’s bundle ID/app ID suffixed with `.push-type.widgets`.
public var topic: String

/// The date when the notification is no longer valid and can be discarded. If this value is not `none`,
/// APNs stores the notification and tries to deliver it at least once,
/// repeating the attempt as needed if it is unable to deliver the notification the first time.
/// If the value is `immediately`, APNs treats the notification as if it expires immediately
/// and does not store the notification or attempt to redeliver it.
public var expiration: APNSNotificationExpiration

/// The priority of the notification.
public var priority: APNSPriority

/// Initializes a new ``APNSWidgetsNotification``.
///
/// - Parameters:
/// - expiration: The date when the notification is no longer valid and can be discarded.
/// - priority: The priority of the notification.
/// - appID: Your app’s bundle ID/app ID. This will be suffixed with `.push-type.widgets`.
/// - apnsID: A canonical UUID that identifies the notification.
@inlinable
public init(
expiration: APNSNotificationExpiration,
priority: APNSPriority,
appID: String,
apnsID: UUID? = nil
) {
self.init(
expiration: expiration,
priority: priority,
topic: appID + ".push-type.widgets",
apnsID: apnsID
)
Expand All @@ -80,19 +64,13 @@ public struct APNSWidgetsNotification: APNSMessage {
/// Initializes a new ``APNSWidgetsNotification``.
///
/// - Parameters:
/// - expiration: The date when the notification is no longer valid and can be discarded.
/// - priority: The priority of the notification.
/// - topic: The topic for the notification. In general, the topic is your app’s bundle ID/app ID suffixed with `.push-type.widgets`.
/// - apnsID: A canonical UUID that identifies the notification.
@inlinable
public init(
expiration: APNSNotificationExpiration,
priority: APNSPriority,
topic: String,
apnsID: UUID? = nil
) {
self.expiration = expiration
self.priority = priority
self.topic = topic
self.apnsID = apnsID
}
Expand Down
13 changes: 2 additions & 11 deletions Tests/APNSTests/Widgets/APNSWidgetsNotificationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,12 @@ import XCTest

final class APNSWidgetsNotificationTests: XCTestCase {
func testAppID() {
let widgetsNotification = APNSWidgetsNotification(
expiration: .none,
priority: .immediately,
appID: "com.example.app"
)

let widgetsNotification = APNSWidgetsNotification(appID: "com.example.app")
XCTAssertEqual(widgetsNotification.topic, "com.example.app.push-type.widgets")
}

func testEncode() throws {
let widgetsNotification = APNSWidgetsNotification(
expiration: .none,
priority: .immediately,
appID: "com.example.app"
)
let widgetsNotification = APNSWidgetsNotification(appID: "com.example.app")

let encoder = JSONEncoder()
let data = try encoder.encode(widgetsNotification)
Expand Down