-
Notifications
You must be signed in to change notification settings - Fork 1
/
xmpp_handshake.xml
356 lines (304 loc) · 9.96 KB
/
xmpp_handshake.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
XMPP Handshake with Google FCM server.
--------------------------------------
<!-- Client --->
<stream:stream to="gcm.googleapis.com"
version="1.0" xmlns="jabber:client"
xmlns:stream="http://etherx.jabber.org/streams"/>
<auth mechanism="PLAIN"
xmlns="urn:ietf:params:xml:ns:xmpp-sasl">MTI2MjAwMzQ3OTMzQHByb2plY3RzLmdjbS5hb
mFTeUIzcmNaTmtmbnFLZEZiOW1oekNCaVlwT1JEQTJKV1d0dw==
</auth>
<!--authenticated, start stream -->
<stream:stream to="gcm.googleapis.com"
version="1.0" xmlns="jabber:client"
xmlns:stream="http://etherx.jabber.org/streams">
<iq type="set">
<bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"></bind>
</iq>
<message id="123">
<gcm xmlns="google:mobile:data">
JSON payload
</gcm>
</message>
<message id="124">
<gcm xmlns="google:mobile:data">
JSON payload
</gcm>
</message>
<message id="125">
<gcm xmlns="google:mobile:data">
JSON payload
</gcm>
</message>
</stream:stream>
<!-- Server -->
<stream:stream from="gcm.googleapis.com"
id="A89EBEF93CBB12CF" version="1.0"
xmlns:stream="http://etherx.jabber.org/streams"
xmlns="jabber:client">
<stream:features>
<mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl">
<mechanism>X-OAUTH2</mechanism>
<mechanism>X-GOOGLE-TOKEN</mechanism>
<mechanism>PLAIN</mechanism>
</mechanisms>
</stream:features>
<success xmlns="urn:ietf:params:xml:ns:xmpp-sasl"/>
<stream:features>
<bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"/>
<session xmlns="urn:ietf:params:xml:ns:xmpp-session"/>
</stream:features>
<iq type="result">
<bind xmlns="urn:ietf:params:xml:ns:xmpp-bind">
<jid>SENDER_ID@gcm.googleapis.com/RESOURCE</jid>
</bind>
</iq>
<message id="">
<gcm xmlns="google:mobile:data">
JSON payload
</gcm>
</message>
<message id="">
<gcm xmlns="google:mobile:data">
JSON payload
</gcm>
</message>
<message id="">
<gcm xmlns="google:mobile:data">
JSON payload
</gcm>
</message>
</stream:stream>
<!-- XMPP handshake sequence with FCM Server -->
<!-- Client --->
<stream:stream to="gcm.googleapis.com"
version="1.0" xmlns="jabber:client"
xmlns:stream="http://etherx.jabber.org/streams"/>
<!-- Server -->
<stream:stream from="gcm.googleapis.com"
id="A89EBEF93CBB12CF" version="1.0"
xmlns:stream="http://etherx.jabber.org/streams"
xmlns="jabber:client">
<stream:features>
<mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl">
<mechanism>X-OAUTH2</mechanism>
<mechanism>X-GOOGLE-TOKEN</mechanism>
<mechanism>PLAIN</mechanism>
</mechanisms>
</stream:features>
<!-- Client --->
<auth mechanism="PLAIN"
xmlns="urn:ietf:params:xml:ns:xmpp-sasl">MTI2MjAwMzQ3OTMzQHByb2plY3RzLmdjbS5hb
mFTeUIzcmNaTmtmbnFLZEZiOW1oekNCaVlwT1JEQTJKV1d0dw==
</auth>
<!-- Server -->
<success xmlns="urn:ietf:params:xml:ns:xmpp-sasl"/>
<!-- Client --->
<stream:stream to="gcm.googleapis.com"
version="1.0" xmlns="jabber:client"
xmlns:stream="http://etherx.jabber.org/streams">
<!-- Server -->
<stream:features>
<bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"/>
<session xmlns="urn:ietf:params:xml:ns:xmpp-session"/>
</stream:features>
<!-- Client --->
<iq type="set">
<bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"></bind>
</iq>
<!-- Server -->
<iq type="result">
<bind xmlns="urn:ietf:params:xml:ns:xmpp-bind">
<jid>SENDER_ID@gcm.googleapis.com/RESOURCE</jid>
</bind>
</iq>
<!-- Example upstream message recieved -->
<message to="xxxxx@gcm.googleapis.com" from="devices@gcm.googleapis.com" type="normal">
<gcm xmlns="google:mobile:data">
{"data": {"Hello":"World"},
"time_to_live":10,
"from":"feQqD9P957k:APA91bH-jE8j6dAohIB5spQrCajDwUsDtNdf3",
"message_id":"1234567",
"category":"com.gmail.rajeshkhumanthem.phantom"
}
</gcm>
</message>
<!-- Example ack message send to FCM in response to above -->
<message id="">
<gcm xmlns="google:mobile:data">
{
"to":"feQqD9P957k:APA91bH-jE8j6dAohIB5spQrCajDwUsDtNdf3",
"message_id":"1234567",
"message_type": "ack"
}
</gcm>
</message>
<!-- see https://firebase.google.com/docs/cloud-messaging/xmpp-server-ref for more details. -->
<!-- DOWNSTREAM MESSAGE:
// data message
message id: REQUIRED. STRING. Unique id that identifies this message.
to: OPTIONAL. STRING. Device's registration token, group notification key or a topic/topics.
condition: OPTIONAL: STRING. Logical expression of conditions that determines a target.
priority: OPTIONAL. STRING. Data messagen defaults to 'normal'. Notification defaults to 'High'
collapse_key: OPTIONAL.
content_available: OPTIONAL.
mutable_content: OPRIONAL.
time_to_live: OPTIONAL.Defaults to 4 weeks. Specified in secs.
dry_run: OPTIONAL.
data: OPTIONA, OBJECT. Key/Value pair message payload.
Key shouldnt be a reserved word like to, collapse_key etc.
// notification
message id: REQUIRED. STRING. Unique id that identifies this message.
to: OPTIONAL. STRING. Device's registration token, group notification key or a topic/topics.
condition: OPTIONAL: STRING. Logical expression of conditions that determines a target.
priority: OPTIONAL. STRING. Data messagen defaults to 'normal'. Notification defaults to 'High'
collapse_key: OPTIONAL.
content_available: OPTIONAL.
mutable_content: OPRIONAL.
time_to_live: OPTIONAL.Defaults to 4 weeks. Specified in secs.
dry_run: OPTIONAL.
title: OPTIONAL. STRING.
body OPTIONAL. STRING
sound OPTIONAL. STRING
badge OPTIONAL. STRING
click_action OPTIONAL. STRING
body_loc_key OPTIONAL. STRING
body_loc_args OPTIONAL. JSON array as STRING
title_loc_key OPTIONAL. STRING
title_loc_args OPTIONAL. JSON array as STRING
notification:
-->
<!-- DOWNSTREAM MESSAGE RESPONSE (Ack/Nack):
// Ack specific
message_type: REQUIRED. STRING. Ack
from: REQUIRED. STRING. Specifies who sent this message.
message id: REQUIRED. STRING. Unique id that identifies this message.
registration_id OPTIONAL. STRING. New token id. Update old token
// Nack specific.
message_type: REQUIRED. STRING. Nack
registration_id OPTIONAL. STRING. New token id. Update old token
// check https://firebase.google.com/docs/cloud-messaging/xmpp-server-ref#table4 for more error details.
error: OPTIONAL. STRING.
error_description: OPTIONAL. STRING. Present of message_type = Nack.
-->
<!--CLOUD CONNECTION SERVER MESSAGE (receipt/control):
// receipt specific
message_type: REQUIRED. STRING. receipt
from: REQUIRED. STRING. Specifies who sent this message.
message id: REQUIRED. STRING. Unique id that identifies this message.
category: OPTIONAL. STRING.
data: OPTIONAL. OBJECT.
// control specific
message_type: REQUIRED. STRING. control
control_type: OPTIONAL. STRING. value = CONNECTION_DRAINING
-->
<!-- Example of downstream message send to a client identified by token 'to' -->
<message id="">
<gcm xmlns="google:mobile:data">
{
"data": {
"greeting": "Hello World"
},
"to" : "bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1..."
}
</gcm>
</message>
<!-- Example of downstream message response. -->
<message id="">
<gcm xmlns="google:mobile:data">
{
"from":"bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...",
"message_id":"1366082849205",
"message_type":"ack"
}
</gcm>
</message>
<!-- NACK message from FCM -->
<message>
<data:gcm xmlns:data="google:mobile:data">
{ "message_type":"nack",
"from":"eQq",
"message_id":"800001",
"error":"BAD_REGISTRATION",
"error_description":""
}
</data:gcm>
</message>
<!-- BAL Messages -->
{
message_type = "LOGON",
session_id = "asdfasdfasdf",
status = "",
error_string = "",
fcm_data = {
}
}
{
message_type = "LOGON_RESPONSE",
session_id = "asdfasdfasdf",
status = "SUCCESS",
error_string = "",
fcm_data = {
}
}
<!-- message send from GIMMM to BAL -->
{
message_type = "UPSTREAM",
session_id = "asdfasdfasdf",
message_id = "12345",
status = "",
fcm_data = {
}
}
<!-- sample downstream message recieved from a BAL layer. To be uploaded to FCM -->
{
message_type = "DOWNSTREAM",
session_id = "asdfasdfasdf",
message_id = "12345",
group_id = "",
fcm_data = {
<!--see DOWNSTREAM MESSAGE fields above -->
}
}
<!-- sample downstream message ack sent down to a BAL layer. -->
{
message_type = "DOWNSTREAM_ACK",
session_id = "asdfasdfasdf",
message_id = "12345",
group_id = "",
fcm_data ={
<!--see DOWNSTREAM RESPONSE MESSAGE fields above -->
}
}
<!-- sample downstream message reciept forwarded to a BAL layer. -->
{
message_type = "DOWNSTREAM_RECIEPT",
session_id = "asdfasdfasdf",
message_id = "12345",
group_id = "",
fcm_data ={
<!--see DOWNSTREAM RECEIPT MESSAGE fields above -->
}
}
<!-- sample downstream message reciept sent down to a BAL layer. -->
{
message_type = "DOWNSTREAM_REJECT",
session_id = "asdfasdfasdf",
message_id = "12345",
group_id = "",
error_string = "Some Error"
}
<!-- receipt message -->
{
"category": "com.gmail.rajeshkhumanthem.seabus",
"data": {
"device_registration_id": "feQxxxxxxxa",
"message_sent_timestamp": "1498801519251",
"message_status": "MESSAGE_SENT_TO_DEVICE",
"original_message_id": "39"
},
"from": "gcm.googleapis.com",
"message_id": "dr2:39",
"message_type": "receipt",
"time_to_live": 0
}