APNSwift 0.3.1

APNSwift 0.3.1

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Sep 2016
SPMSupports SPM

Maintained by Kaunteya Suryawanshi.


Downloads

Total38
Week0
Month0

Installs

Apps11
powered by Segment

GitHub

Stars5
Watchers1
Forks2
Issues0
Contributors1
Pull Requests0

Code

Files5
LOCLines of Code 216


APNSwift 0.3.1

  • By
  • Kaunteya Suryawanshi

APNSwift

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

Features

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

Installation

Usage

APNS Connection can be created by SecIdentity or PKCS certificate file

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