问题
I have connected my project to the webhook that GetStream provide. The access is established, but i only receive the single-notification and not the aggregated-notification.
The idea is to connect the webhook to a push-notification service.
I have had a look at their documentation: https://getstream.io/docs/ios/#realtime-webhooks, where they provide an example. But i can only access the single-notification as i see it.
[
{
"deleted":[],
"new":[{"actor":"1","verb":"tweet","object":"1","target":null,"time":"2014-12-15T17:20:37.258","foreign_id":null,"id":"af781804-847e-11e4-8080-80012fb97b9e","tweet":"Hello world"}],
"published_at":"2014-12-15T17:20:37.263518+00:00",
"feed":"user:2",
"app_id": "123"
},
{
"deleted":["38f81366-847f-11e4-9c94-0cc47a024be0"],
"new":[],
"published_at":"2014-12-15T17:20:37.263518+00:00",
"feed":"timeline:1",
"app_id": "123"
}
]
I was thinking about querying the aggregated-notification or single-notification to check if it already exist, but the only way is to query it by foreign-key and it's not the aggregation-keys.
I want to know if i somehow can get the aggregated-notification (activity_count). Instead of getting every single-notification, because the idea is the send a push-notification for every created aggregated-notification only.
回答1:
It is impossible to receive an aggregated notification via realtime notification system. Grouping is happening at feed read time but notification is sent the moment you add an activity to feed so grouping information is not available at that time.
You could read the feed with limit of 1 to get check which group activity ended up in
回答2:
When you receive the notification through the webhook, you can use the activity data and the aggregation format you set up for your feed to build the aggregation identifier and then retrieve additional information about the group your activities will contain group information (notice the group
field). For example when adding an activity to a notification feed you might get data like this:
[
{
"new": [
{
"actor": "jhon",
"foreign_id": "foood:1",
"group": "eat_2019-01-13",
"heat": "very",
"id": "36d466f4-1715-11e9-8080-800169b0b807",
"object": "food:1336",
"origin": null,
"target": "",
"time": "2019-01-13T09:25:49.315250",
"verb": "eat"
}
],
"deleted": [],
"feed": "timeline_aggregated:feed_id",
"app_id": xxxxx,
"published_at": "2019-06-13T14:47:31.368Z"
}
]
来源:https://stackoverflow.com/questions/56543022/is-there-a-way-to-retrieve-the-aggregated-notification-from-getstream-webhook