APNSwift 0.3.1

APNSwift 0.3.1

测试已测试
语言语言 SwiftSwift
许可证 MIT
发布日期上次发布2016年9月
SPM支持 SPM

Kaunteya Suryawanshi 维护。



APNSwift 0.3.1

  • Kaunteya Suryawanshi

APNSwift

使用 Swift 编写的 HTTP/2 Apple Push Notification Service (APNs) 推送提供商

功能

  • 使用新的 HTTP/2 协议发送通知
  • 发送通知到 iOS、tvOS 和 macOS 应用

安装

使用

APNS 连接可以由 SecIdentityPKCS 证书文件 创建

guard let apns = APNS(certificatePath: "/path/to/PKCS/certificate", passphrase: "********") else {
    //Failed to create APNS object
    return nil
}

let apnsConnection = APNS(identity: certificateIdentity)

推送通知选项

var apnsOptions = APNS.Options()
apnsOptions.development = true
apnsOptions.port = APNS.Options.Port.p443

推送

try! apnsConnection.sendPush(tokenList: tokens, payload: jsonPayLoad) {
    (apnsResponse) in
    Swift.print("\n\(apnsResponse.deviceToken)")
    Swift.print("  Status: \(apnsResponse.serviceStatus)")
    Swift.print("  APNS ID: \(apnsResponse.apnsId ?? "")")
    if let errorReason = apnsResponse.errorReason {
        Swift.print("  ERROR: \(errorReason)")
    }
}