Latest 0.3.0
Homepage https://github.com/cgossain/LocalNotificationCenter
License MIT
Platforms ios 10.3
Frameworks UserNotifications
Authors

CI Status
Version
License
Platform

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Installation

LocalNotificationCenter is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod 'LocalNotificationCenter'

Usage Instructions

LocalNotificationCenter is a lightweight wrapper around the UserNotifications
framework, and can be used to easily schedule and manage local notifications on
iOS.

Notification Context

Every instance of LocalNotificationCenter maintains its own context. The default notification center uses a default context, however it’s possible to create instances with separate contexts.

All actions performed in a LocalNotificationCenter instance pertain to its own context only.

/// Scoped to the default context.
let defaultNotificationCenter = LocalNotificationCenter.default

/// Scoped to a unique context.
let uniqueNotificationCenter = LocalNotificationCenter(context: "my_unique_context")

Scheduling a Local Notification

// create a unique identifier for this notification (i.e. some database id)
let identifier = <Some Unique Identifier>

// repeat monthly on the 24th day, at 8:30am
let date = DateComponents()
date.day = 24
date.hour = 8
date.minutes = 30

// schedule a new one
LocalNotificationCenter.default.scheduleLocalNotification(withIdentifier: identifier,
                                                          body: message,
                                                          dateMatching: date,
                                                          repeats: true)

Cancelling a Single Pending Local Notification

You can cancel a previously scheduled notification via its unique identifier.

LocalNotificationCenter.default.cancelScheduledLocalNotification(forIdentifier: identifier)

Cancelling All Pending Local Notifications

In some cases, you might want to cancel all previously scheduled notifications within the context.

LocalNotificationCenter.default.cancelAllScheduledLocalNotifications()

Author

cgossain, [email protected]

License

LocalNotificationCenter is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "LocalNotificationCenter",
    "version": "0.3.0",
    "summary": "A lightweight library for scheduling local notifications on iOS, written in Swift.",
    "description": "The LocalNotificationCenter was writted to enable a very simple and efficient way to manage localnnotifications on iOS. It offers a very simple interface, and the powerful concept of context basednnotification centers.",
    "homepage": "https://github.com/cgossain/LocalNotificationCenter",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "cgossain": "[email protected]"
    },
    "source": {
        "git": "https://github.com/cgossain/LocalNotificationCenter.git",
        "tag": "0.3.0"
    },
    "platforms": {
        "ios": "10.3"
    },
    "swift_version": "5.0",
    "source_files": "LocalNotificationCenter/Classes/**/*",
    "frameworks": "UserNotifications"
}

Pin It on Pinterest

Share This