Files
Commilitia-Drop/desktop/platform/notify_darwin.go
T

36 lines
1.1 KiB
Go

//go:build darwin
package platform
/*
#cgo darwin CFLAGS: -x objective-c -fobjc-arc
#cgo darwin LDFLAGS: -framework Foundation -framework UserNotifications
#include <stdlib.h>
void cdropNotify(const char *title, const char *body);
*/
import "C"
import "unsafe"
// InitializeNotifications is a no-op on macOS; the notification center is
// initialized lazily by the native framework.
func InitializeNotifications() {}
// Notify shows a native system notification.
//
// macOS uses UNUserNotificationCenter, which REQUIRES the app bundle to be
// code-signed with a valid bundle identifier (see desktop/PLAN.md D3/D6). On an
// unsigned / ad-hoc build the ObjC side detects the missing bundle proxy and
// no-ops rather than crashing — so this is safe to call from the current build;
// it simply won't display until the signing + notarization pipeline (D6) ships.
//
// Safe to call from any goroutine: the native work hops to the main queue.
func Notify(title, body string) {
ct := C.CString(title)
cb := C.CString(body)
defer C.free(unsafe.Pointer(ct))
defer C.free(unsafe.Pointer(cb))
C.cdropNotify(ct, cb)
}