9 #import <objc/runtime.h> 10 #include <Cocoa/Cocoa.h> 14 - (NSString *)__bundleIdentifier
16 if (
self == [NSBundle mainBundle]) {
17 return @"org.ravenfoundation.Raven-Qt";
19 return [
self __bundleIdentifier];
27 if(this->hasUserNotificationCenterSupport()) {
29 QByteArray utf8 = title.toUtf8();
30 char* cString = (
char *)utf8.constData();
31 NSString *titleMac = [[NSString alloc] initWithUTF8String:cString];
34 cString = (
char *)utf8.constData();
35 NSString *textMac = [[NSString alloc] initWithUTF8String:cString];
38 id userNotification = [[NSClassFromString(@"NSUserNotification") alloc] init];
39 [userNotification performSelector:@selector(setTitle:) withObject:titleMac];
40 [userNotification performSelector:@selector(setInformativeText:) withObject:textMac];
42 id notificationCenterInstance = [NSClassFromString(@"NSUserNotificationCenter") performSelector:@selector(defaultUserNotificationCenter)];
43 [notificationCenterInstance performSelector:@selector(deliverNotification:) withObject:userNotification];
47 [userNotification release];
53 Class possibleClass = NSClassFromString(
@"NSUserNotificationCenter");
56 if(possibleClass!=nil) {
69 Class aPossibleClass = objc_getClass(
"NSBundle");
73 method_exchangeImplementations(class_getInstanceMethod(aPossibleClass,
@selector(bundleIdentifier)),
74 class_getInstanceMethod(aPossibleClass,
@selector(__bundleIdentifier)));
bool hasUserNotificationCenterSupport(void)
check if OS can handle UserNotifications
static MacNotificationHandler * instance()
void showNotification(const QString &title, const QString &text)
shows a macOS 10.8+ UserNotification in the UserNotificationCenter
Macintosh-specific notification handler (supports UserNotificationCenter).