Skip to content

Commit f09f565

Browse files
PubNub SDK v4.35.0 release.
1 parent b127e08 commit f09f565

34 files changed

Lines changed: 2268 additions & 144 deletions

‎.pubnub.yml‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,21 @@
11
name: java
2-
version: 4.33.3
2+
version: 4.35.0
33
schema: 1
44
scm: github.com/pubnub/java
55
files:
6-
- build/libs/pubnub-gson-4.33.3-all.jar
6+
- build/libs/pubnub-gson-4.35.0-all.jar
77
changelog:
8+
- version: v4.35.0
9+
date: 2020-11-24
10+
changes:
11+
- type: feature
12+
text: "Support for fileMessagePublishRetryLimit."
13+
- type: bug
14+
text: "Enable SDK users either to ignore PNAccessDeniedCategoryError occurred inside Subscription Loop or to react to in inside status callback."
15+
- type: bug
16+
text: "Report proper error message when upload file too large."
17+
- type: bug
18+
text: "Add missing auth and signature in generated URLs."
819
- version: v4.33.3
920
date: 2020-10-21
1021
changes:

‎CHANGELOG.md‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
## [v4.35.0](https://github.com/pubnub/java/releases/tag/v4.35.0)
2+
November-24-2020
3+
4+
[Full Changelog](https://github.com/pubnub/java/compare/v4.33.3...v4.35.0)
5+
6+
- 🌟️ Support for fileMessagePublishRetryLimit.
7+
- 🐛 Enable SDK users either to ignore PNAccessDeniedCategoryError occurred inside Subscription Loop or to react to in inside status callback.
8+
- 🐛 Report proper error message when upload file too large.
9+
- 🐛 Add missing auth and signature in generated URLs.
10+
111
## [v4.33.3](https://github.com/pubnub/java/releases/tag/v4.33.3)
212
October-21-2020
313

‎README.md‎

Lines changed: 197 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
2-
31
# PubNub Java-based SDKs for Java / Android
42

53
[![Build Status](https://travis-ci.org/pubnub/java.svg?branch=master)](https://travis-ci.org/pubnub/java)
@@ -8,8 +6,202 @@
86
[![Download](https://api.bintray.com/packages/bintray/jcenter/com.pubnub%3Apubnub-gson/images/download.svg)](https://bintray.com/bintray/jcenter/com.pubnub%3Apubnub-gson/_latestVersion)
97
[![Maven Central](https://img.shields.io/maven-central/v/com.pubnub/pubnub-gson.svg)]()
108

11-
### [Documentation](https://www.pubnub.com/docs/java/pubnub-java-sdk-v4)
9+
This is the official PubNub Java SDK repository.
10+
11+
PubNub takes care of the infrastructure and APIs needed for the realtime communication layer of your application. Work on your app's logic and let PubNub handle sending and receiving data across the world in less than 100ms.
12+
13+
## Get keys
14+
15+
You will need the publish and subscribe keys to authenticate your app. Get your keys from the [Admin Portal](https://dashboard.pubnub.com/login).
16+
17+
## Configure PubNub
18+
19+
1. Integrate the Java SDK into your project:
20+
21+
* for Maven, add the following dependency in your `pom.xml`:
22+
```xml
23+
<dependency>
24+
<groupId>com.pubnub</groupId>
25+
<artifactId>pubnub-gson</artifactId>
26+
<version>4.33.3</version>
27+
</dependency>
28+
```
29+
30+
* for Gradle, add the following dependency in your `gradle.build`:
31+
```groovy
32+
compile group: 'com.pubnub', name: 'pubnub-gson', version: '4.33.3'
33+
```
34+
35+
2. Configure your keys:
36+
37+
```java
38+
PNConfiguration pnConfiguration = new PNConfiguration();
39+
pnConfiguration.setSubscribeKey("mySubscribeKey");
40+
pnConfiguration.setPublishKey("myPublishKey");
41+
pnConfiguration.setUuid("myUniqueUUID");
42+
43+
PubNub pubnub = new PubNub(pnConfiguration);
44+
```
45+
46+
## Add event listeners
47+
48+
```java
49+
// SubscribeCallback is an Abstract Java class. It requires that you implement all Abstract methods of the parent class even if you don't need all the handler methods.
50+
51+
pubnub.addListener(new SubscribeCallback() {
52+
// PubNub status
53+
@Override
54+
public void status(PubNub pubnub, PNStatus status) {
55+
switch (status.getOperation()) {
56+
// combine unsubscribe and subscribe handling for ease of use
57+
case PNSubscribeOperation:
58+
case PNUnsubscribeOperation:
59+
// Note: subscribe statuses never have traditional errors,
60+
// just categories to represent different issues or successes
61+
// that occur as part of subscribe
62+
switch (status.getCategory()) {
63+
case PNConnectedCategory:
64+
// No error or issue whatsoever.
65+
case PNReconnectedCategory:
66+
// Subscribe temporarily failed but reconnected.
67+
// There is no longer any issue.
68+
case PNDisconnectedCategory:
69+
// No error in unsubscribing from everything.
70+
case PNUnexpectedDisconnectCategory:
71+
// Usually an issue with the internet connection.
72+
// This is an error: handle appropriately.
73+
case PNAccessDeniedCategory:
74+
// PAM does not allow this client to subscribe to this
75+
// channel and channel group configuration. This is
76+
// another explicit error.
77+
default:
78+
// You can directly specify more errors by creating
79+
// explicit cases for other error categories of
80+
// `PNStatusCategory` such as `PNTimeoutCategory` or
81+
// `PNMalformedFilterExpressionCategory` or
82+
// `PNDecryptionErrorCategory`.
83+
}
84+
85+
case PNHeartbeatOperation:
86+
// Heartbeat operations can in fact have errors,
87+
// so it's important to check first for an error.
88+
// For more information on how to configure heartbeat notifications
89+
// through the status PNObjectEventListener callback, refer to
90+
// /docs/android-java/api-reference-configuration#configuration_basic_usage
91+
if (status.isError()) {
92+
// There was an error with the heartbeat operation, handle here
93+
} else {
94+
// heartbeat operation was successful
95+
}
96+
default: {
97+
// Encountered unknown status type
98+
}
99+
}
100+
}
101+
102+
// Messages
103+
@Override
104+
public void message(PubNub pubnub, PNMessageResult message) {
105+
String messagePublisher = message.getPublisher();
106+
System.out.println("Message publisher: " + messagePublisher);
107+
System.out.println("Message Payload: " + message.getMessage());
108+
System.out.println("Message Subscription: " + message.getSubscription());
109+
System.out.println("Message Channel: " + message.getChannel());
110+
System.out.println("Message timetoken: " + message.getTimetoken());
111+
}
112+
113+
// Presence
114+
@Override
115+
public void presence(@NotNull PubNub pubnub, @NotNull PNPresenceEventResult presence) {
116+
System.out.println("Presence Event: " + presence.getEvent());
117+
// Can be join, leave, state-change or timeout
118+
119+
System.out.println("Presence Channel: " + presence.getChannel());
120+
// The channel to which the message was published
121+
122+
System.out.println("Presence Occupancy: " + presence.getOccupancy());
123+
// Number of users subscribed to the channel
124+
125+
System.out.println("Presence State: " + presence.getState());
126+
// User state
127+
128+
System.out.println("Presence UUID: " + presence.getUuid());
129+
// UUID to which this event is related
130+
131+
presence.getJoin();
132+
// List of users that have joined the channel (if event is 'interval')
133+
134+
presence.getLeave();
135+
// List of users that have left the channel (if event is 'interval')
136+
137+
presence.getTimeout();
138+
// List of users that have timed-out off the channel (if event is 'interval')
139+
140+
presence.getHereNowRefresh();
141+
// Indicates to the client that it should call 'hereNow()' to get the
142+
// complete list of users present in the channel.
143+
}
144+
145+
// Signals
146+
@Override
147+
public void signal(PubNub pubnub, PNSignalResult pnSignalResult) {
148+
System.out.println("Signal publisher: " + signal.getPublisher());
149+
System.out.println("Signal payload: " + signal.getMessage());
150+
System.out.println("Signal subscription: " + signal.getSubscription());
151+
System.out.println("Signal channel: " + signal.getChannel());
152+
System.out.println("Signal timetoken: " + signal.getTimetoken());
153+
}
154+
155+
// Message actions
156+
@Override
157+
public void messageAction(PubNub pubnub, PNMessageActionResult pnActionResult) {
158+
PNMessageAction pnMessageAction = pnActionResult.getAction();
159+
System.out.println("Message action type: " + pnMessageAction.getType());
160+
System.out.println("Message action value: " + pnMessageAction.getValue());
161+
System.out.println("Message action uuid: " + pnMessageAction.getUuid());
162+
System.out.println("Message action actionTimetoken: " + pnMessageAction.getActionTimetoken());
163+
System.out.println("Message action messageTimetoken: " + pnMessageAction.getMessageTimetoken());]
164+
System.out.println("Message action subscription: " + pnActionResult.getSubscription());
165+
System.out.println("Message action channel: " + pnActionResult.getChannel());
166+
System.out.println("Message action timetoken: " + pnActionResult.getTimetoken());
167+
}
168+
169+
// Files
170+
@Override
171+
public void file(PubNub pubnub, PNFileEventResult pnFileEventResult) {
172+
System.out.println("File channel: " + pnFileEventResult.getChannel());
173+
System.out.println("File publisher: " + pnFileEventResult.getPublisher());
174+
System.out.println("File message: " + pnFileEventResult.getMessage());
175+
System.out.println("File timetoken: " + pnFileEventResult.getTimetoken());
176+
System.out.println("File file.id: " + pnFileEventResult.getFile().getId());
177+
System.out.println("File file.name: " + pnFileEventResult.getFile().getName());
178+
System.out.println("File file.url: " + pnFileEventResult.getFile().getUrl());
179+
}
180+
});
181+
```
182+
183+
## Publish/subscribe
184+
185+
```java
186+
pubnub.publish().channel(channelName)
187+
.message(messageJsonObject)
188+
.async((result, publishStatus) -> {
189+
if (!publishStatus.isError()) {
190+
// Message successfully published to specified channel.
191+
} else { // Request processing failed.
192+
// Handle message publish error
193+
// Check 'category' property to find out
194+
// issues because of which the request failed.
195+
// Request can be resent using: [status retry];
196+
}
197+
});
198+
```
199+
200+
## Documentation
201+
202+
* [API reference for Java ](https://www.pubnub.com/docs/java-se-java/pubnub-java-sdk)
203+
* [API reference for Android](https://www.pubnub.com/docs/android-java/pubnub-java-sdk)
12204

13-
## Communication
205+
## Support
14206

15-
- If you **need any help** or have a **general question**, contact <support@pubnub.com>
207+
If you **need help** or have a **general question**, contact support@pubnub.com.

‎build.gradle‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ plugins {
1111
}
1212
group = 'com.pubnub'
1313

14-
version = '4.33.3'
14+
version = '4.35.0'
1515

1616
description = """"""
1717

-36.4 MB
Binary file not shown.

0 commit comments

Comments
 (0)