Code Monkey home page Code Monkey logo

nsusernotificationprivate's Introduction

NSUserNotificationPrivate

Private API showcase for NSUserNotification

Example app

Around OS X, you can see quite a few features in the Notification Center API (NSUserNotification et. al) that aren't being exposed to developers publicly. For example, the way that iTunes uses album artwork in place of its icon.

I class-dumped the NSUserNotification header and quickly found how to access these features and put together an example app to make it easy to try each one. Here's an overview of the private stuff I found (there's probably more):

(NOTE: This should go without saying, but using any of this will result in your app being rejected from the MAS and potentially breaking if the APIs change. This is just for fun.)

Identity Image

This is how iTunes swaps in album artwork for the icon. When the _identityImage property is set, it shows the set image in place of the icon and moves the app icon to the left of the notification title. The default value of nil makes it use the app icon. The result looks like this:

Identity image

There's even an option to turn off the default border by setting the _identityImageHasBorder to NO.

Ignore Do Not Disturb

The _ignoresDoNotDisturb property allows you to override the user's Do Not Disturb settings and post the notification anyways. Default value is NO.

Lockscreen Only

The _lockscreenOnly property allows you to make it so that a notification is only posted if the computer is locked. This means that you can only see the missed notification in the lock screen and it disappears as soon as you unlock the computer. Default value is NO.

Poofs on Cancel

If the notification type is set to "Alert", the _poofsOnCancel property lets you configure whether there should be a poof animation when the Cancel button is clicked. Default value is YES.

Show Alternate Action Menu

If the notification type is set to "Alert", the alternateActionButtonTitles property lets you set an array of additional menu item titles to be shown in an action menu that can be accessed by hovering on the Action button and clicking on the arrow. It looks like this:

Action items

Once a notification is handled, the index of the action can be retrieved using the _alternateActionIndex property.

License

There's hardly any code here, do whatever you want with it.

nsusernotificationprivate's People

Contributors

indragiek avatar

Watchers

James Cloos avatar Fisher Lee avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.