8 #import <objc/runtime.h> 9 #include <Cocoa/Cocoa.h> 13 - (NSString *)__bundleIdentifier
15 if (
self == [NSBundle mainBundle]) {
16 return @"org.bitcoinfoundation.BSHA3-Qt";
18 return [
self __bundleIdentifier];
26 if(this->hasUserNotificationCenterSupport()) {
28 QByteArray utf8 = title.toUtf8();
29 char* cString = (
char *)utf8.constData();
30 NSString *titleMac = [[NSString alloc] initWithUTF8String:cString];
33 cString = (
char *)utf8.constData();
34 NSString *textMac = [[NSString alloc] initWithUTF8String:cString];
37 id userNotification = [[NSClassFromString(@"NSUserNotification") alloc] init];
38 [userNotification performSelector:@selector(setTitle:) withObject:titleMac];
39 [userNotification performSelector:@selector(setInformativeText:) withObject:textMac];
41 id notificationCenterInstance = [NSClassFromString(@"NSUserNotificationCenter") performSelector:@selector(defaultUserNotificationCenter)];
42 [notificationCenterInstance performSelector:@selector(deliverNotification:) withObject:userNotification];
46 [userNotification release];
52 Class possibleClass = NSClassFromString(
@"NSUserNotificationCenter");
55 if(possibleClass!=nil) {
68 Class aPossibleClass = objc_getClass(
"NSBundle");
72 method_exchangeImplementations(class_getInstanceMethod(aPossibleClass,
@selector(bundleIdentifier)),
73 class_getInstanceMethod(aPossibleClass,
@selector(__bundleIdentifier)));
bool hasUserNotificationCenterSupport()
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).