1 module fcm.FCMRequest;
2 
3 import vibe.data.json;
4 
5 /**
6  * Targets, options, and payload for downstream HTTP messages (JSON).
7  * 
8  * https://firebase.google.com/docs/cloud-messaging/http-server-ref#table1
9  */
10 struct FCMRequest
11 {
12 	// Targets
13 	
14 	/**
15 	 * This parameter specifies the recipient of a message.
16 	 * 
17 	 * The value must be a registration token, notification key, or
18 	 * topic. Do not set this field when sending to multiple topics.
19 	 * See condition.
20 	 */
21 	//@optional
22 	//@name("to")
23 	//string to;
24 	
25 	/**
26 	 * This parameter specifies a list of devices (registration tokens,
27 	 * or IDs) receiving a multicast message. It must contain at least
28 	 * 1 and at most 1000 registration tokens.
29 	 * 
30 	 * Use this parameter only for multicast messaging, not for single
31 	 * recipients. Multicast messages (sending to more than 1
32 	 * registration tokens) are allowed using HTTP JSON format only.
33 	 */
34 	@name("registration_ids")
35 	string[] registrationIds = null;
36 
37 	/**
38 	 * This parameter specifies a logical expression of conditions that
39 	 * determine the message target.
40 	 * 
41 	 * Supported condition: Topic, formatted as "'yourTopic' in topics".
42 	 * This value is case-insensitive.
43 	 * 
44 	 * Supported operators: &&, ||. Maximum two operators per topic
45 	 * message supported.
46 	 */
47 	//@optional
48 	//@name("condition")
49 	//string condition = null;
50 
51 	/**
52 	 * This parameter is deprecated. Instead, use to to specify message
53 	 * recipients. For more information on how to send messages to
54 	 * multiple devices, see the documentation for your platform.
55 	 */
56 	//@optional
57 	//@name("notification_key")
58 	//deprecated string notificationKey = null;
59 
60 	// Options
61 	
62 	/**
63 	 * This parameter identifies a group of messages (e.g., with
64 	 * collapse_key: "Updates Available") that can be collapsed, so
65 	 * that only the last message gets sent when delivery can be
66 	 * resumed. This is intended to avoid sending too many of the
67 	 * same messages when the device comes back online or becomes
68 	 * active.
69 	 * 
70 	 * Note that there is no guarantee of the order in which messages
71 	 * get sent.
72 	 * 
73 	 * Note: A maximum of 4 different collapse keys is allowed at
74 	 * any given time. This means a FCM connection server can
75 	 * simultaneously store 4 different send-to-sync messages per
76 	 * client app. If you exceed this number, there is no guarantee
77 	 * which 4 collapse keys the FCM connection server will keep.
78 	 */
79 	//@optional
80 	//@name("collapse_key")
81 	//string collapseKey = null;
82 
83 	/**
84 	 * Sets the priority of the message. Valid values are "normal"
85 	 * and "high." On iOS, these correspond to APNs priorities 5 and 10.
86 	 * 
87 	 * By default, notification messages are sent with high priority,
88 	 * and data messages are sent with normal priority. Normal priority
89 	 * optimizes the client app's battery consumption and should be
90 	 * used unless immediate delivery is required. For messages with
91 	 * normal priority, the app may receive the message with
92 	 * unspecified delay.
93 	 * 
94 	 * When a message is sent with high priority, it is sent
95 	 * immediately, and the app can wake a sleeping device and open a
96 	 * network connection to your server.
97 	 * 
98 	 * For more information, see Setting the priority of a message.
99 	 * 
100 	 * https://firebase.google.com/docs/cloud-messaging/concept-options#setting-the-priority-of-a-message
101 	 */
102 	//@optional
103 	//@name("priority")
104 	//string priority = null;
105 	
106 	/**
107 	 * On iOS, use this field to represent content-available in the
108 	 * APNs payload. When a notification or message is sent and this
109 	 * is set to true, an inactive client app is awoken. On Android,
110 	 * data messages wake the app by default. On Chrome, currently not
111 	 * supported.
112 	 */
113 	//@optional
114 	//@name("content_available")
115 	//bool contentAvailable;
116 	
117 	/**
118 	 * This parameter specifies how long (in seconds) the message
119 	 * should be kept in FCM storage if the device is offline. The
120 	 * maximum time to live supported is 4 weeks, and the default
121 	 * value is 4 weeks. For more information, see Setting the
122 	 * lifespan of a message.
123 	 * 
124 	 * https://firebase.google.com/docs/cloud-messaging/concept-options#ttl
125 	 */
126 	//@optional
127 	//@name("time_to_live")
128 	//int timeToLive;
129 	
130 	/**
131 	 * This parameter specifies the package name of the application
132 	 * where the registration tokens must match in order to receive
133 	 * the message.
134 	 */
135 	//@optional
136 	//@name("restricted_package_name")
137 	//string restrictedPackageName = null;
138 	
139 	/**
140 	 * This parameter, when set to true, allows developers to test a
141 	 * request without actually sending a message.
142 	 * 
143 	 * The default value is false.
144 	 */
145 	//@optional
146 	//@name("dry_run")
147 	//bool dryRun;
148 	
149 	// Payload
150 
151 	/**
152 	 * This parameter specifies the custom key-value pairs of the
153 	 * message's payload.
154 	 * 
155 	 * For example, with data:{"score":"3x1"}:
156 	 * 
157 	 * On iOS, if the message is sent via APNS, it represents the
158 	 * custom data fields. If it is sent via FCM connection server,
159 	 * it would be represented as key value dictionary in AppDelegate
160 	 * application:didReceiveRemoteNotification:.
161 	 * 
162 	 * On Android, this would result in an intent extra named score
163 	 * with the string value 3x1.
164 	 * 
165 	 * The key should not be a reserved word ("from" or any word
166 	 * starting with "google" or "gcm"). Do not use any of the words
167 	 * defined in this table (such as collapse_key).
168 	 * 
169 	 * Values in string types are recommended. You have to convert
170 	 * values in objects or other non-string data types (e.g.,
171 	 * integers or booleans) to string.
172 	 */
173 	@optional
174 	@name("data")
175 	Json data = null;
176 
177 	/**
178 	 * This parameter specifies the predefined, user-visible key-value
179 	 * pairs of the notification payload. See Notification payload
180 	 * support for detail. For more information about notification
181 	 * message and data message options, see Payload:
182 	 * https://firebase.google.com/docs/cloud-messaging/concept-options#notifications_and_data_messages
183 	 */
184 	//@optional
185 	//@name("notification")
186 	//Json notification = null;
187 }