如何使用回复按钮(和自定义)实现高级通知

sah*_*108 5 macos push-notification apple-push-notifications uilocalnotification osx-yosemite

我们希望使用Apple推送通知制作本机应用程序.我们希望使用Apple推送通知制作本机应用程序.问题是我们想要在用户悬停在系统上时自定义系统通知.我们注意到,当您将鼠标悬停在通知上时,Skype可以显示"回复"按钮Skype通知.
有谁知道如何创建像Skype那样的通知?我们也希望能够做出其他一些修改:

  1. 在悬停时显示不同的通知.
  2. 在悬停时显示不同的通知,最好是自定义视图,可能包括图像或webview?

谢谢.

更新:

我发现Skype不使用APNS来推送新消息(当Skype没有运行时,当新消息到达时你不会看到通知).屏幕上的通知是本地通知.因此,在我使用远程通知的情况下,我忽略alert远程通知有效负载的密钥,当应用程序收到远程通知时,它将从中删除此通知Notification Center并推送新的本地通知.这是代码:

func application(application: NSApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject]) {
    println(userInfo)
    // remove the remote one
    let deliveredNotifications = NSUserNotificationCenter.defaultUserNotificationCenter().deliveredNotifications
    if let lastRemoteNotif = deliveredNotifications.last as? NSUserNotification {
        NSUserNotificationCenter.defaultUserNotificationCenter().removeDeliveredNotification(lastRemoteNotif)
    }

    // push another local notification
    let localNotif =  NSUserNotification()
    localNotif.title = ""
    localNotif.deliveryDate = NSDate()
    localNotif.title = "CeillingNinja"
    localNotif.subtitle = "This is local notification"
    localNotif.informativeText = "Some text"
    localNotif.contentImage = NSImage(named: "Status")
    NSUserNotificationCenter.defaultUserNotificationCenter().deliverNotification(localNotif)
}
Run Code Online (Sandbox Code Playgroud)

但是当应用程序未运行时,用户将看到一个空通知Notification Center.我仍然坚持到那一点!