5
5
import ibt .ortc .extensibility .OnConnected ;
6
6
import ibt .ortc .extensibility .OnException ;
7
7
import ibt .ortc .extensibility .OnMessage ;
8
+ import ibt .ortc .extensibility .OnMessageWithPayload ;
8
9
import ibt .ortc .extensibility .OrtcClient ;
9
10
import ibt .ortc .extensibility .OrtcFactory ;
10
11
import rtmchat .realtime .co .rtmchat .R ;
20
21
import android .support .v4 .app .NotificationCompat ;
21
22
import android .util .Log ;
22
23
24
+ import java .util .Map ;
25
+
23
26
public class MyService extends Service {
24
27
25
28
private static final String TAG = "MyService" ;
@@ -36,18 +39,26 @@ public void onCreate() {
36
39
factory = ortc .loadOrtcFactory ("IbtRealtimeSJ" );
37
40
client = factory .createClient ();
38
41
client .setHeartbeatActive (true );
39
- Ortc .setOnPushNotification (new OnMessage () {
42
+ Ortc .setOnPushNotification (new OnMessageWithPayload () {
40
43
@ 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
+
49
59
}
50
60
});
61
+
51
62
client .setApplicationContext (getApplicationContext ());
52
63
client .setGoogleProjectId (Config .PROJECT_ID );
53
64
} catch (Exception e ) {
0 commit comments