diff --git a/RTMChat/app/build.gradle b/RTMChat/app/build.gradle index a617aad..6d74bfa 100644 --- a/RTMChat/app/build.gradle +++ b/RTMChat/app/build.gradle @@ -23,5 +23,5 @@ dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:21.0.+' compile 'com.google.android.gms:play-services:6.1.+' - compile 'co.realtime:messaging-android:2.1.34' + compile 'co.realtime:messaging-android:2.1.48' } diff --git a/RTMChat/app/src/main/java/services/MyService.java b/RTMChat/app/src/main/java/services/MyService.java index 3521db3..41a421f 100644 --- a/RTMChat/app/src/main/java/services/MyService.java +++ b/RTMChat/app/src/main/java/services/MyService.java @@ -5,6 +5,7 @@ import ibt.ortc.extensibility.OnConnected; import ibt.ortc.extensibility.OnException; import ibt.ortc.extensibility.OnMessage; +import ibt.ortc.extensibility.OnMessageWithPayload; import ibt.ortc.extensibility.OrtcClient; import ibt.ortc.extensibility.OrtcFactory; import rtmchat.realtime.co.rtmchat.R; @@ -20,6 +21,8 @@ import android.support.v4.app.NotificationCompat; import android.util.Log; +import java.util.Map; + public class MyService extends Service { private static final String TAG = "MyService"; @@ -36,18 +39,26 @@ public void onCreate() { factory = ortc.loadOrtcFactory("IbtRealtimeSJ"); client = factory.createClient(); client.setHeartbeatActive(true); - Ortc.setOnPushNotification(new OnMessage() { + Ortc.setOnPushNotification(new OnMessageWithPayload() { @Override - public void run(OrtcClient sender, final String channel, final String message) { - Log.i(TAG, String.format("Push notification on channel %s: %s", channel, message)); - if(!MessageActivity.isInForeground() && !NotificationActivity.isInForeground()) { - String parts [] = message.split(":"); - String user = parts[0].split("_")[parts[0].split("_").length - 1]; - String msg = parts[1]; - displayNotification(channel, user,msg); - } + public void run(OrtcClient sender, final String channel, final String message, Map payload) { + + if(payload != null) { + Log.i(TAG, String.format("Push notification on channel %s: %s payload: %s", channel, message, payload.toString())); + }else{ + Log.i(TAG, String.format("Push notification on channel %s: %s ", channel, message)); + } + + if(!MessageActivity.isInForeground() && !NotificationActivity.isInForeground()) { + String parts [] = message.split(":"); + String user = parts[0].split("_")[parts[0].split("_").length - 1]; + String msg = parts[1]; + displayNotification(channel, user,msg); + } + } }); + client.setApplicationContext(getApplicationContext()); client.setGoogleProjectId(Config.PROJECT_ID); } catch (Exception e) {