 //import AWSiOSSDKv2
 
 @NSApplicationMain
-class AppDelegate: NSObject, NSApplicationDelegate, AppMenuDataSource, AccountControllerObserver, NSMenuDelegate {
+class AppDelegate: NSObject, NSApplicationDelegate, AppMenuDataSource, AccountControllerObserver, NSMenuDelegate, NSUserNotificationCenterDelegate {
     let updateInterval: NSTimeInterval = 60 /* minutes */ * 60 /* seconds */
     
     //Main app directory for storing data

        appMenu.refreshMenu()

        //Open Preferences if there are no accounts configured
        if accountController.accounts.count == 0 {
            self.preferences(nil)
        }
        
        //Refresh the list once in a while
        NSTimer.scheduledTimerWithTimeInterval(updateInterval, target: self, selector: Selector("refresh"), userInfo: nil, repeats: true)

        //Refreh the list of accounts when the menu opens
        self.refresh()
    }
    
    

}

private let _NotificationManager = NotificationManager()
class NotificationManager : NSObject, NSUserNotificationCenterDelegate {
    
    class func sharedManager() -> NotificationManager {
        return _NotificationManager
    }
    
    func showNotification(title: String, informativeText: String){
        var notification = NSUserNotification()
        
        notification.title = title
        notification.informativeText = informativeText
        notification.deliveryDate = NSDate()
        
        NSUserNotificationCenter.defaultUserNotificationCenter().delegate = self
        
        NSUserNotificationCenter.defaultUserNotificationCenter().scheduleNotification(notification)
    }
    
    func userNotificationCenter(center: NSUserNotificationCenter, shouldPresentNotification notification: NSUserNotification) -> Bool {
        return true
    }
}



