Latest 0.1.7
Homepage https://github.com/sunuslee/SULUserNotificationCenter
License MIT
Platforms osx 10.9
Authors

Example

The left one is delivered by SULUserNotificationCenter

A Drop in replacement for NSUserNotification with a few handy tweaks, written in Swift 3.0!

See the example by pod try SULUserNotificationCenter

Install

pod "SULUserNotificationCenter"

Getting Started

deliver usernotification

Just replace your NSUserNotificationCenter to SULUserNotificationCenter
See below


// ********REPLACE this line
// let NScenter = NSUserNotificationCenter.default
// ********With this line
let SULcenter = SULUserNotificationCenter.default

let notification = NSUserNotification.init()
notification.title = "SUL_Notification Title"
notification.subtitle = "SUL subtitle"
notification.informativeText = "SULUserNotification is a dropin replacement for NSUserNotification"
notification.actionButtonTitle = "REPLY"
notification.otherButtonTitle = "Close"
notification.contentImage = NSImage.init(named: "right-icon")

// you can custom this leftImage.
notification.leftImage = NSImage.init(named: "left-icon")
notification.deliveryDate = NSDate.init(timeIntervalSinceNow: 20) as Date
notification.hasReplyButton = true
notification.responsePlaceholder = "Response Placeholder"
notification.replyButtonTitle = "SUL_REPLY"

// ***********REPLACE this line
//NScenter.deliver(notification)

// ***********With this line
SULcenter.deliver(notification)

Delegates

Replace NSUserNotificationCenterDelegate With SULUserNotificationCenterDelegate

extension ViewController{

    // Replace the first two delegate methods
    func userNotificationCenter(_ center: NSUserNotificationCenter, shouldPresent notification: NSUserNotification) -> Bool {
        return true;
    }

    func userNotificationCenter(_ center: NSUserNotificationCenter, didActivate notification: NSUserNotification) {
        #if DEBUG
        Swift.print("Function: (type(of:self)) (#function), line: (#line)")
        #endif
        print("NSUserNotification Did Active")
    }

    // With this two delegate methods
    func userNotificationCenter(_ center: SULUserNotificationCenter, shouldPresent notification: NSUserNotification) -> Bool {
        #if DEBUG
        Swift.print("Function: (type(of:self)) (#function), line: (#line)")
        #endif
        return true
    }

    func userNotificationCenter(_ center: SULUserNotificationCenter, didActivate notification: NSUserNotification) {
        #if DEBUG
        Swift.print("Function: (type(of:self)) (#function), line: (#line)")
        #endif
    }
}

Latest podspec

{
    "name": "SULUserNotificationCenter",
    "version": "0.1.7",
    "summary": "A Drop in replacement for NSUserNotification with a few handy tweaks, written in Swift 3.0!",
    "description": "A Drop in replacement for NSUserNotification with a few handy tweaks, written in Swift 3.0!nSee Example for more detail!",
    "homepage": "https://github.com/sunuslee/SULUserNotificationCenter",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "sunuslee": "[email protected]"
    },
    "source": {
        "git": "https://github.com/sunuslee/SULUserNotificationCenter.git",
        "tag": "0.1.7"
    },
    "platforms": {
        "osx": "10.9"
    },
    "source_files": "SULUserNotificationCenter/Classes/**/*",
    "resource_bundles": {
        "SULUserNotificationCenter": [
            "SULUserNotificationCenter/Assets/*.xib"
        ]
    },
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This