Skip to content

Commit 5519d0a

Browse files
author
Devendra
committed
fixing connect callback issue
1 parent 28cba81 commit 5519d0a

3 files changed

Lines changed: 31 additions & 4 deletions

File tree

android/examples/PubnubSubscribe/src/com/pubnub/examples/pubnubsubscribe/PubnubActivity.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@
1111
import com.pubnub.examples.pubnubsubscribe.R;
1212

1313
import android.app.Activity;
14+
import android.app.Notification;
1415
import android.app.NotificationManager;
1516
import android.app.PendingIntent;
1617
import android.content.BroadcastReceiver;
1718
import android.content.Context;
1819
import android.content.Intent;
1920
import android.content.IntentFilter;
21+
import android.graphics.Color;
2022
import android.media.Ringtone;
2123
import android.media.RingtoneManager;
2224
import android.net.Uri;
@@ -50,13 +52,15 @@ private void sendNotification(String msg) {
5052
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(
5153
this).setSmallIcon(R.drawable.icon)
5254
.setContentTitle("PubNub Notification")
55+
.setLights(Color.RED, 3000, 3000)
56+
.setVibrate(new long[] { 1000, 1000, 1000, 1000, 1000 } )
5357
.setStyle(new NotificationCompat.BigTextStyle().bigText(msg))
5458
.setContentText(msg);
5559

5660
mBuilder.setContentIntent(contentIntent);
5761
mBuilder.setAutoCancel(true);
5862
mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build());
59-
63+
6064
try {
6165
Uri notification = RingtoneManager
6266
.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);

android/examples/PubnubSubscribe/src/com/pubnub/examples/pubnubsubscribe/PubnubService.java

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@
1616
import com.pubnub.api.PubnubError;
1717
import com.pubnub.api.PubnubException;
1818

19+
import android.app.Notification;
1920
import android.app.NotificationManager;
2021
import android.app.PendingIntent;
2122
import android.app.Service;
2223
import android.content.Context;
2324
import android.content.Intent;
25+
import android.graphics.Color;
2426
import android.os.IBinder;
2527
import android.support.v4.app.NotificationCompat;
2628
import android.util.Log;
@@ -66,13 +68,15 @@ private void sendNotification(String msg) {
6668
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(
6769
this).setSmallIcon(R.drawable.icon)
6870
.setContentTitle("PubNub Notification")
71+
.setLights(Color.RED, 3000, 3000)
72+
.setVibrate(new long[] { 1000, 1000, 1000, 1000, 1000 } )
6973
.setStyle(new NotificationCompat.BigTextStyle().bigText(msg))
7074
.setContentText(msg);
7175

7276
mBuilder.setContentIntent(contentIntent);
7377
mBuilder.setAutoCancel(true);
7478
mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build());
75-
79+
7680
try {
7781
Uri notification = RingtoneManager
7882
.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
@@ -135,7 +139,26 @@ public void onCreate() {
135139
Log.i("PUBNUB", "PubnubService created...");
136140

137141
try {
138-
pubnub.subscribe(new String[]{public_channel, device_channel}, new Callback() {
142+
pubnub.subscribe(public_channel, new Callback() {
143+
@Override
144+
public void connectCallback(String channel, Object message) {
145+
try {
146+
pubnub.subscribe(device_channel, new Callback() {
147+
@Override
148+
public void successCallback(String channel, Object message) {
149+
notifyUser((JSONObject) message);
150+
}
151+
152+
@Override
153+
public void errorCallback(String channel, Object message) {
154+
notifyUser((JSONObject) message);
155+
}
156+
});
157+
} catch (PubnubException e) {
158+
Log.i("PUBNUB", e.toString());
159+
}
160+
}
161+
139162
@Override
140163
public void successCallback(String channel, Object message) {
141164
notifyUser((JSONObject) message);

java/src1/com/pubnub/api/SubscribeWorker.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ void process(HttpRequest hreq) {
2121
log.verbose("disconnectAndResubscribe is " + hreq.isDar());
2222
if (hreq.getWorker() != null) {
2323
log.verbose("Request placed by worker " + hreq.getWorker().getThread().getName());
24-
if (hreq.getWorker()._die) {
24+
if (hreq.getWorker()._die && !hreq.isSubzero()) {
2525
log.verbose("The thread which placed the request has died, so ignore the request : " + hreq.getWorker().getThread().getName());
2626
return;
2727
}

0 commit comments

Comments
 (0)