types.go (2423B)
1 package notify 2 3 type ( 4 CategoryID = string 5 ActionID = string 6 UserText = string 7 UserData = map[string]string 8 ) 9 10 // CallbackArgs contains the data from a user interaction of a notification. 11 type CallbackArgs struct { 12 Category CategoryID 13 Action ActionID 14 UserData UserData // data attached to the notification by the application 15 UserText string // text input by the user (applies to text actions) 16 Err error // any error that occured processing the user data 17 } 18 19 // CallbackFunc signature. Switch on the action to know how to interpret the dynamic data. 20 type CallbackFunc func(CallbackArgs) 21 22 // Category defines a set of actions that a notification can reference by ID to 23 // have them be applied. 24 type Category struct { 25 ID CategoryID 26 Summary string // summarise the category 27 Preview string // hidden preview body placeholder 28 Actions []Action 29 TextInputActions []TextInputAction 30 } 31 32 // Notification describes 33 type Notification struct { 34 Title string 35 Subtitle string 36 Body string 37 38 // UserData is app supplied data that is passed back upon user interaction. 39 UserData UserData 40 41 // Attachments is a list of image names. 42 // If the image name is an absolute path it will be followed literally. 43 // If the image name is just a base name, the bundle will be searched for it. 44 // The named image must exist on disk, must be PNG, JPEG or GIF and must be 45 // less than 10MB. 46 Attachments []string 47 48 // Category to apply. If supplied the actions attached on this notification will be 49 // ignored and the pre-existing category used. 50 Category CategoryID 51 52 // Actions, if supplied here, will provoke an ad-hoc Category to be created to 53 // contain them on the native side. This is for convenience. 54 Actions []Action // button action 55 TextInputActions []TextInputAction // text input action 56 } 57 58 // Action is a button action. 59 type Action struct { 60 ID ActionID // globally unique, used in callback 61 Title string 62 Icon string // name of asset within bundle to use as icon; TODO: could support system defined icons as well 63 } 64 65 // TextInputAction allows for text input from user. 66 type TextInputAction struct { 67 ID ActionID // globally unique, used in callback 68 Title string 69 Icon string // name of asset within bundle to use as icon; TODO: could support system defined icons as well 70 ButtonTitle string 71 Placeholder string 72 }