fn create_notification_delivery_handler()

in native/desktop-macos/src/macos/notifications.rs [143:166]


    fn create_notification_delivery_handler(
        notification_identifier: Retained<NSString>,
        callback: NotificationDeliveryCallback,
    ) -> RcBlock<dyn Fn(*mut NSError)> {
        RcBlock::new(move |error: *mut NSError| {
            catch_panic(|| {
                let error_msg = if error.is_null() {
                    RustAllocatedStrPtr::null().to_auto_drop()
                } else {
                    let error_ref = unsafe { &*error };
                    copy_to_c_string(&error_ref.localizedDescription())
                        .expect("Error converting to c string")
                        .to_auto_drop()
                };
                let identifier = copy_to_c_string(&notification_identifier)
                    .expect("Error converting to c string")
                    .to_auto_drop();
                dispatch_to_main_if_needed(move || {
                    callback(identifier, error_msg);
                });
                Ok(())
            });
        })
    }