You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Create an Ably Realtime client specifying the clientId that will
255
+
// be associated with annotations published by this client
256
+
let options =ARTClientOptions(key: "{{API_KEY}}")
257
+
options.clientId="my-client-id"
258
+
let realtime =ARTRealtime(options: options)
259
+
260
+
// Create a channel in a namespace called `annotations`
261
+
// which has message annotations enabled
262
+
let channel = realtime.channels.get("annotations:example")
263
+
264
+
// Publish an annotation for a message that flags it as delivered
265
+
let annotation =ARTOutboundAnnotation(
266
+
id: nil,
267
+
type: "receipts:flag.v1",
268
+
clientId: nil,
269
+
name: "delivered",
270
+
count: nil,
271
+
data: nil,
272
+
extras: nil
273
+
)
274
+
channel.annotations.publish(for: message, annotation: annotation) { error in
275
+
// Handle error if needed
276
+
}
277
+
278
+
// You can also use a message's `serial`
279
+
channel.annotations.publish(forMessageSerial: messageSerial, annotation: annotation) { error in
280
+
// Handle error if needed
281
+
}
282
+
```
252
283
</Code>
253
284
254
285
In the case of the `distinct`, `unique`, or `multiple` aggregation types, you should also specify a `name`. For these types, each different name will be aggregated separately in the [annotation summary](#annotation-summaries).
channel.annotations.publish(forMessageSerial: message.serial, annotation: annotation) { error in
327
+
// Handle error if needed
328
+
}
329
+
```
283
330
</Code>
284
331
285
332
You can additionally specify a `data` payload when publishing an annotation. This is not included in an annotation summary, so only readable by [clients that are subscribed to individual annotation events](#individual-annotations).
0 commit comments