noti.h (1584B)
1 //go:build darwin && cgo 2 3 #ifndef GO_NOTI_H 4 #define GO_NOTI_H 5 6 #include <stdint.h> 7 8 // cchar_t encodes const information such that Go code can declare const char * and avoid 9 // compiler warnings related to implicitly casting away the const. 10 typedef const char cchar_t; 11 12 typedef struct Action { 13 char *id; 14 char *title; 15 char *icon; 16 17 } Action; 18 19 typedef struct TextInputAction { 20 char *id; 21 char *title; 22 char *button_title; 23 char *placeholder; 24 char *icon; 25 26 } TextInputAction; 27 28 typedef struct Notification { 29 char *title; 30 char *sub_title; 31 char *body; 32 char *user_data; // JSON encoded data; unmarshal into NSDictionary. 33 char **attachments; 34 uintptr_t attachments_len; 35 36 char *category_id; 37 38 // Actions will be used to create an ad-hoc category prior to issuing the notification. 39 Action *actions; 40 uintptr_t actions_len; 41 TextInputAction *text_input_actions; 42 uintptr_t text_input_actions_len; 43 44 } Notification; 45 46 typedef struct Category { 47 char *id; 48 char *summary; 49 char *preview; 50 Action *actions; 51 uintptr_t actions_len; 52 TextInputAction *text_input_actions; 53 uintptr_t text_input_actions_len; 54 55 } Category; 56 57 // setup registers the app delegate; called automatically by Go package. 58 void 59 noti_setup(); 60 61 // notify pushes a notification. 62 void 63 noti_notify(Notification n); 64 65 // noti_category_register adds a notification category. 66 void 67 noti_category_register(Category category); 68 69 // cancel removes a pushed notification. 70 void 71 noti_cancel(); 72 73 #endif