将 activity 添加到通知源时无法在下拉列表中看到通知

Unable to see the notification in the dropdown when activity is added to the notification feed

我正在努力让自己的头脑清醒过来 getstream.io。我打算用它来实现通知功能。

我在客户端使用反应组件StreamApp。在服务器端,我使用 Java 客户端。 我可以将 activity 添加到通知提要中。我也在客户端收到有关此通知的通知。但是,我无法在下拉列表中看到该通知以及其他现有通知。

前端(客户端)端代码:

<StreamApp
      apiKey="apikey"
      appId="appId"                                            token="token here">
         <NotificationDropdown notify />
</StreamApp>

服务器端(后端)代码:

       Client client = Client.builder("api key", "secret key").build();
        NotificationFeed feed = client.notificationFeed("notification", "user-one");
        Activity activity = Activity.builder()
                .actor("Mr Beans")
                .verb("like")
                .object("hello world")
                .build();
        feed.addActivity(activity).join();

当我 运行 服务器端代码时,我在前端收到通知气泡。但是,当我单击铃铛图标时,我看不到显示 "Mr Beans liked hello world" 的通知。但是,我可以看到现有的,如下所示。

任何关于如何查看我正在发布的 activity 的帮助都将非常有用。提前致谢。

注意:我使用的 api 密钥和令牌来自文档中的示例。

此致, V

您正在尝试创建代表用户反应的 activity。

正确的做法是通过反应 api:

client.reactions().add(
    "user-one",                             // user ID
    "like",                                 // reaction name
    "ccc38e3e-7def-11e9-9154-127939012af0", // activity user is reacting to
    new FeedID("notification", "user-one")  // feed we want to receive an activity
).join();                                   // representing the reaction

如果您绝对需要自己创建活动 - 您有两个选择:

  1. 复制 activity 流生成的格式:
import static io.getstream.core.utils.Enrichment.createUserReference;
...
Activity like = Activity.builder()
    .actor(createUserReference(user.getID())) // user reference
    .verb("like")
    .object("SA:" + targetActivity.getID())   // activity reference
    .build();

Activity follow = Activity.builder()
    .actor(createUserReference(user.getID()))
    .verb("follow")
    .object(createUserReference(targetUser.getID()))
    .build();
  1. 重新实现 NotificationDropdown 呈现方法以支持您的自定义 activity 格式(参见 Notification 组件源代码作为示例):
<StreamApp
    apiKey="<api-key>"
    appId="<app-ID>"
    token="<token>"
>
    <NotificationDropdown notify Group={MyCustomComponent}/>
</StreamApp>