Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/quockhai/kqnotification
Local Notification - Create local, daily, weekly notifications.
https://github.com/quockhai/kqnotification
local notification notification-center notificationcenter swift swift-4 swift4
Last synced: 1 day ago
JSON representation
Local Notification - Create local, daily, weekly notifications.
- Host: GitHub
- URL: https://github.com/quockhai/kqnotification
- Owner: quockhai
- License: mit
- Created: 2018-03-23T16:39:52.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-01-24T04:45:55.000Z (almost 6 years ago)
- Last Synced: 2024-11-13T20:05:50.429Z (7 days ago)
- Topics: local, notification, notification-center, notificationcenter, swift, swift-4, swift4
- Language: Swift
- Homepage:
- Size: 42 KB
- Stars: 3
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# KQNotification
A Swift class which helps you create local, daily, weekly notifications and add actions for user notification easily.## Installation
[Download](https://github.com/quockhai/KQNotification/archive/master.zip) the project and copy the Source folder into your project and then simply you can use it in any file#### Cocoapods
```swift
platform :ios, '10.0'
use_frameworks!pod 'KQUserNotification'
```## Usage
### Register
Register notification in didFinishLaunchingWithOptions
``` swift
KQNotification.shared.registerNotification(withOptions: [.alert, .badge, .sound], completion: nil)
```### Time Notification
``` swift
// Notification after times (seconds)
KQNotification.shared.notification(identifier: "notificationID", title: "KQNotification", body: "Local notification", after: 100, completion: nil)// Notification after times (seconds) and repeat
KQNotification.shared.repeatsNotification(identifier: "repeatNotificationID", title: "KQNotification", body: "Repeat notification", after: 100, completion: nil)// Notification after times (seconds) with actions
let snoozeAction = UNNotificationAction(identifier: "Snooze", title: "Snooze", options: [])
let deleteAction = UNNotificationAction(identifier: "Delete", title: "Delete", options: [.destructive])
KQNotification.shared.actionsNotification(identifier: "actionNotificationID", title: "KQNotification", body: "Actions notification", actions: [snoozeAction, deleteAction], after: 60, repeats: true, completion: nil)
```### Daily Notification
``` swift
// Daily notification
KQNotification.shared.dailyNotification(identifier: "dailyNotificationID", title: "KQNotification", body: "Daily notification", date: Date(), completion: nil)// Daily notification with actions
let snoozeAction = UNNotificationAction(identifier: "Snooze", title: "Snooze", options: [])
let deleteAction = UNNotificationAction(identifier: "Delete", title: "Delete", options: [.destructive])
KQNotification.shared.dailyActionsNotification(identifier: "dailyNotificationID", title: "KQNotification", body: "Daily notification with actions", actions: [snoozeAction, deleteAction], date: Date(), completion: nil)
```### Weekly Notification
``` swift
// Daily notification
KQNotification.shared.weeklyNotification(identifier: "weeklyNotificationID", title: "KQNotification", body: "Weekly notification", date: Date(), completion: nil)// Daily notification with actions
let snoozeAction = UNNotificationAction(identifier: "Snooze", title: "Snooze", options: [])
let deleteAction = UNNotificationAction(identifier: "Delete", title: "Delete", options: [.destructive])
KQNotification.shared.weeklyActionsNotification(identifier: "weeklyNotificationID", title: "KQNotification", body: "Weekly notification with actions", actions: [snoozeAction, deleteAction], date: Date(), completion: nil)
```### Notification delegate
```swift
// Set delegate
KQNotification.shared.notificationCenter.delegate = self// Implement UNUserNotificationCenterDelegate
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
switch response.actionIdentifier {
case UNNotificationDefaultActionIdentifier:
print("Default action")case UNNotificationDismissActionIdentifier:
print("Dismiss action")case "Snooze":
print("Snooze")case "Delete":
print("Delete")default:
print("Unknown action")
break}
completionHandler()
}func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
completionHandler([.alert, .sound])
}
```License
--------The MIT License (MIT)
Copyright (c) 2015 Quoc Khai