【发布时间】:2026-01-14 22:25:01
【问题描述】:
我正在为 Growl 1.3.1 SDK 开发一个小型包装器。更具体地说,我想将 Growl 打包到我的应用程序中,这样即使用户没有 Growl,他们仍然能够收到通知。我之前安装了 Growl,我的代码会触发通知。我已经卸载了 Growl 并且只使用了框架;雾,我相信它被称为。但是,当我现在启动代码(Growl 已卸载)时,不会触发任何通知!以下是我目前正在使用的代码:
#import "growlwrapper.h"
void showGrowlMessage(std::string title, std::string desc) {
std::cout << "[Growl] showGrowlMessage() called." << std::endl;
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
[GrowlApplicationBridge setGrowlDelegate: @""];
[GrowlApplicationBridge
notifyWithTitle: [NSString stringWithUTF8String:title.c_str()]
description: [NSString stringWithUTF8String:desc.c_str()]
notificationName: @"Upload"
iconData: nil
priority: 0
isSticky: NO
clickContext: nil
];
[pool drain];
}
int main() {
showGrowlMessage("Hello World!", "This is a test of the growl system");
return 0;
}
我也有相应的 Growl Registration 字典,并且正在编译:
g++ growlwrapper.mm -framework Growl -framework Foundation -o growltest
这段代码有什么问题吗?任何想法为什么它不会被触发?
编辑:似乎上面的代码运行良好。只需要在运行循环中使用适当的 Growl 字典即可。
【问题讨论】:
-
我不确定,但是当我使用 Growl 时,Growl 桥只会尝试与 Growl 服务通信以显示通知。如果它没有找到它,它本身不会显示通知。因此,如果您没有安装 Growl,则不会显示任何通知。
-
好的,我可以看到在没有安装 Growl 的情况下显示通知是 1.3SDK 功能
标签: c++ objective-c macos objective-c++ growl