Skip to content

A lightweight framework to schedule and cancel local notifications.

License

Notifications You must be signed in to change notification settings

e-sites/Palladium

Repository files navigation

Palladium

Palladium is part of the E-sites iOS Suite.


A lightweight framework to schedule and cancel local notifications.

forthebadge forthebadge

Platform Carthage compatible Travis-ci

Installation

Podfile:

pod 'Palladium'

And then

pod install

Implementation

import Palladium

func authorize() {
    Palladium.shared.requestAuthorization { error in
        print("Authorization result: \(String(describing: error))")
    }
}

func schedule() {
    let content = UNMutableNotificationContent()
    content.body = "This is a notification"
    content.title = Date().description
    var metaData = MetaData(id: "123")
    metaData.tags = [ "tag1", "tag2" ]
    let date = Date(timeIntervalSinceNow: 5)
    Palladium.shared.add(content: content, in: metaData, at: date) { request, error in
        print("Scheduled: \(String(describing: request)), error: \(String(describing: error))")
    }
}

func cancel() {
    Palladium.shared.cancelNotifications(tags: [ "tag2" ]) { identifiers, error in
        print("Cancelled: \(identifiers?.count ?? 0), error: \(String(describing: error))")
    }
}