11package io .jchat .android ;
22
3- import android .app .ProgressDialog ;
43import android .content .Context ;
54import android .content .Intent ;
65import android .graphics .Bitmap ;
@@ -85,21 +84,13 @@ public class JMessageModule extends ReactContextBaseJavaModule {
8584 private static final String ERR_MSG_CONVERSATION = "Can't get the conversation" ;
8685 private static final String ERR_MSG_MESSAGE = "No such message" ;
8786
88- private boolean mShutdownToast ;
89- private ProgressDialog mDialog ;
9087 private Context mContext ;
91- private String mPath ;
92- private Uri mUri ;
93- private Callback mCallback ;
94- private String mUsername ;
9588 private JMessageUtils mJMessageUtils ;
9689
9790 public JMessageModule (ReactApplicationContext reactContext , boolean shutdownToast ) {
9891 super (reactContext );
99- JMessageClient .registerEventReceiver (this );
10092 mJMessageUtils = new JMessageUtils (reactContext , shutdownToast );
10193 mContext = reactContext ;
102- mShutdownToast = shutdownToast ;
10394 }
10495
10596 @ Override
@@ -113,31 +104,15 @@ public boolean canOverrideExistingModule() {
113104 }
114105
115106 @ ReactMethod
116- public void init (int mode ) {
117- if (mode >= 0 && mode <= 4 ) {
118- JMessageClient .setNotificationMode (mode );
119- String modeStr ;
120- switch (mode ) {
121- case 0 :
122- modeStr = "NOTI_MODE_NO_NOTIFICATION" ;
123- break ;
124- case 2 :
125- modeStr = "NOTI_MODE_NO_SOUND" ;
126- break ;
127- case 3 :
128- modeStr = "NOTI_MODE_NO_VIBRATE" ;
129- break ;
130- case 4 :
131- modeStr = "NOTI_MODE_SILENCE" ;
132- break ;
133- default :
134- modeStr = "NOTI_MODE_DEFAULT" ;
135- break ;
136- }
137- Log .i (TAG , "Set NotificationMode: " + modeStr );
107+ public void init (ReadableMap map ) {
108+ try {
109+ boolean isOpenMessageRoaming = map .getBoolean (Constant .IS_OPEN_MESSAGE_ROAMING );
110+ JMessageClient .init (getReactApplicationContext (), isOpenMessageRoaming );
111+ JMessageClient .registerEventReceiver (this );
112+ } catch (Exception e ) {
113+ e .printStackTrace ();
114+ Log .d (TAG , "Parameter invalid, please check again" );
138115 }
139- new NotificationClickEventReceiver (getReactApplicationContext ());
140-
141116 }
142117
143118 @ ReactMethod
0 commit comments