我在 OS X 10.8 中的通知中心遇到了困难。我编写了一个包装器来通过 JNA 提供对 NSUserNotification 和 NSUserNotificationCenter 类的 Java 访问,但功能有限。我能够发送通知,只要 .jar 通过 JavaApplicationStub 从 .app 包运行,它就会显示。但是,当通知样式设置为“警报”时,以下行始终会记录到控制台:
11/29/12 8:37:12.537 PM usernoted[162]: Failed to validate application at (null) -67061
Run Code Online (Sandbox Code Playgroud)
接下来,单击通知会导致以下内容记录到控制台:
11/29/12 8:38:15.291 PM usernoted[162]: Cannot find originating application to launch for event action. file://localhost/Users/geoffodonnell/Projects/bin/GuiTest.app/ is not the same app as the one that sent the original notification.
Run Code Online (Sandbox Code Playgroud)
我确实为 NSUserNotificationCenter 类提供了委托,但是这些方法只有在 .jar 在包之外执行时才会运行。当然,这违背了目的,因为通知永远不会显示。
任何人都可以对上述两个错误提供任何见解吗?
我想知道 JavaApplicationStub 是否妨碍了我,但是当涉及到典型应用程序将如何响应通知中心事件时,我一无所知。