I just wanted to add some notifications to Gyazo app. I finally able to send notifications to the notifications center http://korniltsev.ru/p/jz6m3Nm.png however when i click on it and the app is not launched it launches in some strange way: it shows empty window(even if i set it visibleAtLaunch to 0) and nothing happens;http://korniltsev.ru/p/jz6mvk0.png
我只是想向Gyazo app添加一些通知。我终于能够向通知中心http://korniltsev.ru/p/jz6m3Nm.png发送通知但是当我点击它并且应用程序未启动时它以一种奇怪的方式启动:它显示空窗口(即使我将它设置为visibleAtLaunch为0)并且没有任何反应; http://korniltsev.ru/p/jz6mvk0.png
the code i'm trying to use is here:
我试图使用的代码在这里:
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
NSUserNotification * clicked = [[aNotification userInfo]
objectForKey:NSApplicationLaunchUserNotificationKey];
if (clicked){
[NSApp terminate:self];
return;
}
...
I send notifications like this
我发送这样的通知
NSUserNotificationCenter *manager = [NSUserNotificationCenter defaultUserNotificationCenter];
NSUserNotification *urlNotification = [[NSUserNotification alloc]init];
[urlNotification setTitle:appName];
[urlNotification setInformativeText:url];
[manager deliverNotification:urlNotification];
What am i doing wrong?
我究竟做错了什么?
1 个解决方案
#1
1
[NSApp terminate:self]
has a lot of side effects. Are you sure these side effects are not creating your blank window? Have you tried calling [NSApp terminate:self]
immediately in applicationDidFinishLaunching
and making sure you application quits cleanly in every case? If it does not you will likely have to look at what you are doing in your application's document controller (if you have one) and applicationShouldTerminate
.
[NSApp终止:自我]有很多副作用。你确定这些副作用没有创建空白窗口吗?您是否尝试在applicationDidFinishLaunching中立即调用[NSApp terminate:self]并确保应用程序在每种情况下都干净地退出?如果没有,您可能需要查看您在应用程序的文档控制器(如果有的话)和applicationShouldTerminate中正在执行的操作。
#1
1
[NSApp terminate:self]
has a lot of side effects. Are you sure these side effects are not creating your blank window? Have you tried calling [NSApp terminate:self]
immediately in applicationDidFinishLaunching
and making sure you application quits cleanly in every case? If it does not you will likely have to look at what you are doing in your application's document controller (if you have one) and applicationShouldTerminate
.
[NSApp终止:自我]有很多副作用。你确定这些副作用没有创建空白窗口吗?您是否尝试在applicationDidFinishLaunching中立即调用[NSApp terminate:self]并确保应用程序在每种情况下都干净地退出?如果没有,您可能需要查看您在应用程序的文档控制器(如果有的话)和applicationShouldTerminate中正在执行的操作。