📌 Pushover

一个简单的 Pushover API 封装器。 使用它可以从您的工具向您或您用户的设备发送推送通知。

示例

// Create a pushover object with your API token.
let pushover = Pushover(token: "<#API_TOKEN#>")

// Send a simple message directly.
try await pushover.send("Lorem ipsum dolor sit amet.", to: "<#USER_OR_GROUP_KEY#>")

// Use `Notification`s to use more of Pushover's features.
let notification = Notification(message: "Lorem ipsum.", to: "<#USER#>")
    .devices(["iPhone"])
    .url("https://example.com")
    .urlTitle("Dolor sit amet")
    .priority(.high)
    .sound(.intermission)

do {
    let response = try await pushover.send(notification)
    // The request might still have failed due to a wrong API token, exceeded limits or
    // other problems. Be sure to check the response value for more information.
} catch {
    // An error case means that there was a network, server or decoding error.
}

要求

您需要一个 API 令牌,您可以在这里注册。

另请阅读 Pushover API 文档中的对我们的 API 保持友好 部分。

安装

Pushover 可通过 Swift Package Manager 获取。

Package.swift

.package(url: "https://github.com/kiliankoe/pushover", from: "<#latest#>")

贡献者

许可

Pushover 在 MIT 许可证下可用。 有关更多信息,请参见 LICENSE 文件。