I am trying to get my head around getstream.io. I am planning to use it for implementing notification functionality.
I am using the react component StreamApp
on the client side. On the server side I am using Java client.
I am able to add an activity to the notification feed. I get notified on the client side as well about this notification. However, I am not able to see that notification in the dropdown along with other existing notifications.
Front end (client) side code :
<StreamApp
apiKey="apikey"
appId="appId" token="token here">
<NotificationDropdown notify />
</StreamApp>
Server side (backend) code:
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();
When I run the server side code, I get the notification bubble on the front end. however when I click the bell icon, I cannot see the notification which says "Mr Beans liked hello world". However, I can see the existing ones as shown below.
Any help on how can I see the activity that I am publishing would be really great. Thanks in advance.
Note: The api key and token which I am using is from the examples in the documentation.
Regards, V
You are trying to create an activity representing a user reaction.
The proper way of doing this is achieved via reaction 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
If you absolutely need to create the activities yourself - you have two options:
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();
NotificationDropdown
rendering method to support your custom activity format (see Notification component source code as example):<StreamApp
apiKey="<api-key>"
appId="<app-ID>"
token="<token>"
>
<NotificationDropdown notify Group={MyCustomComponent}/>
</StreamApp>