55import ibt .ortc .extensibility .OnConnected ;
66import ibt .ortc .extensibility .OnException ;
77import ibt .ortc .extensibility .OnMessage ;
8+ import ibt .ortc .extensibility .OnMessageWithPayload ;
89import ibt .ortc .extensibility .OrtcClient ;
910import ibt .ortc .extensibility .OrtcFactory ;
1011import rtmchat .realtime .co .rtmchat .R ;
2021import android .support .v4 .app .NotificationCompat ;
2122import android .util .Log ;
2223
24+ import java .util .Map ;
25+
2326public class MyService extends Service {
2427
2528 private static final String TAG = "MyService" ;
@@ -36,18 +39,26 @@ public void onCreate() {
3639 factory = ortc .loadOrtcFactory ("IbtRealtimeSJ" );
3740 client = factory .createClient ();
3841 client .setHeartbeatActive (true );
39- Ortc .setOnPushNotification (new OnMessage () {
42+ Ortc .setOnPushNotification (new OnMessageWithPayload () {
4043 @ Override
41- public void run (OrtcClient sender , final String channel , final String message ) {
42- Log .i (TAG , String .format ("Push notification on channel %s: %s" , channel , message ));
43- if (!MessageActivity .isInForeground () && !NotificationActivity .isInForeground ()) {
44- String parts [] = message .split (":" );
45- String user = parts [0 ].split ("_" )[parts [0 ].split ("_" ).length - 1 ];
46- String msg = parts [1 ];
47- displayNotification (channel , user ,msg );
48- }
44+ public void run (OrtcClient sender , final String channel , final String message , Map <String , Object > payload ) {
45+
46+ if (payload != null ) {
47+ Log .i (TAG , String .format ("Push notification on channel %s: %s payload: %s" , channel , message , payload .toString ()));
48+ }else {
49+ Log .i (TAG , String .format ("Push notification on channel %s: %s " , channel , message ));
50+ }
51+
52+ if (!MessageActivity .isInForeground () && !NotificationActivity .isInForeground ()) {
53+ String parts [] = message .split (":" );
54+ String user = parts [0 ].split ("_" )[parts [0 ].split ("_" ).length - 1 ];
55+ String msg = parts [1 ];
56+ displayNotification (channel , user ,msg );
57+ }
58+
4959 }
5060 });
61+
5162 client .setApplicationContext (getApplicationContext ());
5263 client .setGoogleProjectId (Config .PROJECT_ID );
5364 } catch (Exception e ) {
0 commit comments