aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2014-11-19 10:51:25 +0100
committerWladimir J. van der Laan <laanwj@gmail.com>2014-11-19 10:51:59 +0100
commit5716808ca78143196ec6db111e72a36aff4dd170 (patch)
tree747924cb3864533f16f42370270fc66984166067 /src
parent3b4c7cdfc370e60cf7e3baef29fb16c983908aed (diff)
parenta7f29410681b367620c780453b0abb9688831766 (diff)
Merge pull request #5300
a7f2941 [Qt, OSX] fix usage of osx 10.8+ user notification center (Jonas Schnelli)
Diffstat (limited to 'src')
-rw-r--r--src/qt/macnotificationhandler.mm24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/qt/macnotificationhandler.mm b/src/qt/macnotificationhandler.mm
index 8a4c94cc5c..aa50a0d9fb 100644
--- a/src/qt/macnotificationhandler.mm
+++ b/src/qt/macnotificationhandler.mm
@@ -5,8 +5,21 @@
#include "macnotificationhandler.h"
#undef slots
+#import <objc/runtime.h>
#include <Cocoa/Cocoa.h>
+// Add an obj-c category (extension) to return the expected bundle identifier
+@implementation NSBundle(returnCorrectIdentifier)
+- (NSString *)__bundleIdentifier
+{
+ if (self == [NSBundle mainBundle]) {
+ return @"org.bitcoinfoundation.Bitcoin-Qt";
+ } else {
+ return [self __bundleIdentifier];
+ }
+}
+@end
+
void MacNotificationHandler::showNotification(const QString &title, const QString &text)
{
// check if users OS has support for NSUserNotification
@@ -63,7 +76,16 @@ bool MacNotificationHandler::hasUserNotificationCenterSupport(void)
MacNotificationHandler *MacNotificationHandler::instance()
{
static MacNotificationHandler *s_instance = NULL;
- if (!s_instance)
+ if (!s_instance) {
s_instance = new MacNotificationHandler();
+
+ Class aPossibleClass = objc_getClass("NSBundle");
+ if (aPossibleClass) {
+ // change NSBundle -bundleIdentifier method to return a correct bundle identifier
+ // a bundle identifier is required to use OSXs User Notification Center
+ method_exchangeImplementations(class_getInstanceMethod(aPossibleClass, @selector(bundleIdentifier)),
+ class_getInstanceMethod(aPossibleClass, @selector(__bundleIdentifier)));
+ }
+ }
return s_instance;
}