Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EDU-1438: Adds new Java code example to the 'Publish directly using cl… #2193

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions content/push/publish.textile
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ When you need to deliver push notifications to specific users rather than a sing

A @clientId@ is set during the device "activation":device#device process.

The following example publishes a push notification using the @clientId@:
The following example publishes a push notification using the @clientId@:

```[jsall]
var recipient = {
Expand Down Expand Up @@ -325,17 +325,18 @@ rest.push.admin.publish(recipient, data: data)
```

```[java]
Message message = new Message("example", "rest data");
message.extras = io.ably.lib.util.JsonUtils.object()
.add("push", io.ably.lib.util.JsonUtils.object()
.add("notification", io.ably.lib.util.JsonUtils.object()
.add("title", "Hello from Ably!")
.add("body", "Example push notification from Ably."))
.add("data", io.ably.lib.util.JsonUtils.object()
.add("foo", "bar")
.add("baz", "qux")));

rest.push.admin.publish(arrayOf(Param("clientId", clientId)), message);
JsonObject payload = JsonUtils.object()
.add("notification", JsonUtils.object()
.add("title", "Hello from Ably!")
.add("body", "Example push notification from Ably.")
)
.add("data", JsonUtils.object()
.add("foo", "bar")
.add("baz", "qux")
)
.toJson();

rest.push.admin.publish(new Param[]{new Param("clientId", "xxxxxxxxxxxx")}, payload);
```

```[python]
Expand Down