Inside Bitcoin
Opening the selected file…
Inside Bitcoin
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
1// Copyright (c) 2011-present The Bitcoin Core developers2// Distributed under the MIT software license, see the accompanying3// file COPYING or http://www.opensource.org/licenses/mit-license.php.5#include "macnotificationhandler.h"7#undef slots8#import <objc/runtime.h>9#include <Cocoa/Cocoa.h>11// Add an obj-c category (extension) to return the expected bundle identifier12@implementation NSBundle(returnCorrectIdentifier)13- (NSString *)__bundleIdentifier14{15if (self == [NSBundle mainBundle]) {16return @"org.bitcoinfoundation.Bitcoin-Qt";17} else {18return [self __bundleIdentifier];19}20}21@end23void MacNotificationHandler::showNotification(const QString &title, const QString &text)24{25// check if users OS has support for NSUserNotification26if(this->hasUserNotificationCenterSupport()) {27NSUserNotification* userNotification = [[NSUserNotification alloc] init];28userNotification.title = title.toNSString();29userNotification.informativeText = text.toNSString();30[[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification: userNotification];31[userNotification release];32}33}35bool MacNotificationHandler::hasUserNotificationCenterSupport(void)36{37Class possibleClass = NSClassFromString(@"NSUserNotificationCenter");39// check if users OS has support for NSUserNotification40if(possibleClass!=nil) {41return true;42}43return false;44}47MacNotificationHandler *MacNotificationHandler::instance()48{49static MacNotificationHandler *s_instance = nullptr;50if (!s_instance) {51s_instance = new MacNotificationHandler();53Class aPossibleClass = objc_getClass("NSBundle");54if (aPossibleClass) {55// change NSBundle -bundleIdentifier method to return a correct bundle identifier56// a bundle identifier is required to use OSXs User Notification Center57method_exchangeImplementations(class_getInstanceMethod(aPossibleClass, @selector(bundleIdentifier)),58class_getInstanceMethod(aPossibleClass, @selector(__bundleIdentifier)));59}60}61return s_instance;62}
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.