apns-swift 0.1.0

apns-swift 0.1.0

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Aug 2016
SPMSupports SPM

Maintained by Kaunteya Suryawanshi.


Downloads

Total1
Week0
Month0

Installs

Apps1
powered by Segment

Code

Files5
LOCLines of Code 201


  • By
  • Kaunteya Suryawanshi

apns-swift

HTTP/2 Apple Push Notification Service (APNs) push provider written in Swift

Features

  • Sends notifications using new HTTP/2 protocol
  • Send notifications iOS, tvOS and macOS apps

Usage

APNS Connection can be created by SecIdentity of Path to PKCS certificate

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

let apnsConnection = APNS(identity: certificateIdentity)

Push Notification options

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

Push

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)")
    }
}