Perfect-Notifications
iOS Notifications for Perfect
Building
Add this project as a dependency in your Package.swift file.
.Package(url:"https://github.com/PerfectlySoft/Perfect-Notifications.git", versions: Version(0,0,0)..<Version(10,0,0))
Usage
// BEGIN one-time initialization code
let configurationName = "My configuration name - can be whatever"
NotificationPusher.addConfigurationIOS(configurationName) {
(net:NetTCPSSL) in
// This code will be called whenever a new connection to the APNS service is required.
// Configure the SSL related settings.
net.keyFilePassword = "if you have password protected key file"
guard net.useCertificateChainFile("path/to/entrust_2048_ca.cer") &&
net.useCertificateFile("path/to/aps_development.pem") &&
net.usePrivateKeyFile("path/to/key.pem") &&
net.checkPrivateKey() else {
let code = Int32(net.errorCode())
print("Error validating private key file: \(net.errorStr(code))")
return
}
}
NotificationPusher.development = true // set to toggle to the APNS sandbox server
// END one-time initialization code
// BEGIN - individual notification push
let deviceId = "hex string device id"
let ary = [IOSNotificationItem.AlertBody("This is the message"), IOSNotificationItem.Sound("default")]
let n = NotificationPusher()
n.apnsTopic = "com.company.my-app"
n.pushIOS(configurationName, deviceToken: deviceId, expiration: 0, priority: 10, notificationItems: ary) {
response in
print("NotificationResponse: \(response.code) \(response.body)")
}
// END - individual notification push
Repository Layout
We have finished refactoring Perfect to support Swift Package Manager. The Perfect project has been split up into the following repositories:
- Perfect - This repository contains the core PerfectLib and will continue to be the main landing point for the project.
- PerfectTemplate - A simple starter project which compiles with SPM into a stand-alone executable HTTP server. This repository is ideal for starting on your own Perfect based project.
- PerfectDocs - Contains all API reference related material.
- PerfectExamples - All the Perfect example projects and documentation.
- PerfectEverything - This umbrella repository allows one to pull in all the related Perfect modules in one go, including the servers, examples, database connectors and documentation. This is a great place to start for people wishing to get up to speed with Perfect.
- PerfectServer - Contains the PerfectServer variants, including the stand-alone HTTP and FastCGI servers. Those wishing to do a manual deployment should clone and build from this repository.
- Perfect-Redis - Redis database connector.
- Perfect-SQLite - SQLite3 database connector.
- Perfect-PostgreSQL - PostgreSQL database connector.
- Perfect-MySQL - MySQL database connector.
- Perfect-MongoDB - MongoDB database connector.
- Perfect-FastCGI-Apache2.4 - Apache 2.4 FastCGI module; required for the Perfect FastCGI server variant.
The database connectors are all stand-alone and can be used outside of the Perfect framework and server.
Further Information
For more information on the Perfect project, please visit perfect.org.