Skip to content

Commit bc35955

Browse files
KenChoiKenChoi
authored andcommitted
modify init
1 parent 2437091 commit bc35955

File tree

5 files changed

+9
-635
lines changed

5 files changed

+9
-635
lines changed

android/src/io/jchat/android/Constant.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package io.jchat.android;
22

33
public class Constant {
4+
static final String IS_OPEN_MESSAGE_ROAMING = "isOpenMessageRoaming";
45
static final String ENABLE = "enable";
56
public static final String USERNAME = "username";
67
public static final String PASSWORD = "password";

android/src/io/jchat/android/JMessageModule.java

Lines changed: 8 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package io.jchat.android;
22

3-
import android.app.ProgressDialog;
43
import android.content.Context;
54
import android.content.Intent;
65
import 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

android/src/io/jchat/android/NotificationClickEventReceiver.java

Lines changed: 0 additions & 73 deletions
This file was deleted.

0 commit comments

Comments
 (0)