, , IOS-, . , , .
, , , , .
iOS (, ) , , , , , .
, . , , push-, " ", , .
Daemon - , , App Store. App Store - - 2.8 (, , " " ):
2.8 , ,
, iOS ; , . , , .
Swift (2.0), Darwin, , : / iPhone. , , , , . , . , , , Apple .
( - ), :
import UIKit
import CoreFoundation
class MainViewController: UIViewController, UIWebViewDelegate {
override func viewDidLoad() {
super.viewDidLoad()
var cfstr: CFString = "com.apple.iokit.hid.displayStatus" as NSString
var notificationCenter = CFNotificationCenterGetDarwinNotifyCenter()
CFNotificationCenterAddObserver(notificationCenter, nil,
{ (noti: CFNotificationCenter!, aPtr: UnsafeMutablePointer<Void>, aStr: CFString!, bPtr: UnsafePointer<Void>, aDict: CFDictionary!) -> () in
print("got notification") }, cfstr, nil, CFNotificationSuspensionBehavior.DeliverImmediately)
}
}