CocoaPods trunk is moving to be read-only. Read more on the blog, there are 19 months to go.

APNSwift 0.3.1

APNSwift 0.3.1

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Sep 2016
SPMSupports SPM

Maintained by Kaunteya Suryawanshi.



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