5
5
import android .os .Handler ;
6
6
import android .os .Looper ;
7
7
import android .support .annotation .Nullable ;
8
+ import android .util .Log ;
8
9
9
10
import com .facebook .react .bridge .Arguments ;
10
11
import com .facebook .react .bridge .ReactApplicationContext ;
20
21
21
22
import com .facebook .react .modules .core .DeviceEventManagerModule ;
22
23
import com .instabug .bug .BugReporting ;
24
+ import com .instabug .bug .PromptOption ;
25
+ import com .instabug .bug .invocation .InvocationMode ;
23
26
import com .instabug .bug .invocation .InvocationOption ;
24
27
import com .instabug .chat .InstabugChat ;
28
+ import com .instabug .crash .CrashReporting ;
25
29
import com .instabug .featuresrequest .FeatureRequests ;
26
30
import com .instabug .library .ActionType ;
27
31
import com .instabug .library .Feature ;
54
58
import org .json .JSONException ;
55
59
import org .json .JSONObject ;
56
60
61
+ import java .lang .reflect .Array ;
57
62
import java .lang .reflect .InvocationTargetException ;
58
63
import java .lang .reflect .Method ;
59
64
import java .util .ArrayList ;
@@ -194,19 +199,10 @@ public String getName() {
194
199
return "Instabug" ;
195
200
}
196
201
197
- @ ReactMethod
198
- public void startWithToken (String androidToken , String invocationEvent ) {
199
- mInstabug = new Instabug .Builder (this .androidApplication , androidToken )
200
- .setIntroMessageEnabled (false )
201
- .setInvocationEvent (getInvocationEventById (invocationEvent ))
202
- .build ();
203
- //init placHolders
204
- placeHolders = new InstabugCustomTextPlaceHolder ();
205
-
206
- }
207
-
208
202
/**
209
- * invoke sdk manually
203
+ * invoke sdk manually with mode and options
204
+ *
205
+ * @param
210
206
*/
211
207
@ ReactMethod
212
208
public void invoke () {
@@ -227,25 +223,54 @@ public void run() {
227
223
* invoke sdk manually with desire invocation mode
228
224
*
229
225
* @param invocationMode the invocation mode
226
+ * @param invocationOptions the array of invocation options
230
227
*/
231
228
@ ReactMethod
232
- public void invokeWithInvocationMode (String invocationMode ) {
233
- InstabugInvocationMode mode ;
229
+ public void invokeWithInvocationMode (String invocationMode , ReadableArray invocationOptions ) {
230
+ InvocationMode mode ;
231
+
234
232
235
233
if (invocationMode .equals (INVOCATION_MODE_NEW_BUG )) {
236
- mode = InstabugInvocationMode .NEW_BUG ;
234
+ mode = InvocationMode .NEW_BUG ;
237
235
} else if (invocationMode .equals (INVOCATION_MODE_NEW_FEEDBACK )) {
238
- mode = InstabugInvocationMode .NEW_FEEDBACK ;
236
+ mode = InvocationMode .NEW_FEEDBACK ;
239
237
} else if (invocationMode .equals (INVOCATION_MODE_NEW_CHAT )) {
240
- mode = InstabugInvocationMode .NEW_CHAT ;
238
+ mode = InvocationMode .NEW_CHAT ;
241
239
} else if (invocationMode .equals (INVOCATION_MODE_CHATS_LIST )) {
242
- mode = InstabugInvocationMode .CHATS_LIST ;
240
+ mode = InvocationMode .CHATS_LIST ;
243
241
} else {
244
- mode = InstabugInvocationMode .PROMPT_OPTION ;
242
+ mode = InvocationMode .PROMPT_OPTION ;
243
+ }
244
+
245
+ Log .d ("where is" , invocationMode + " " + mode );
246
+
247
+ Object [] objectArray = ArrayUtil .toArray (invocationOptions );
248
+ String [] stringArray = Arrays .copyOf (objectArray , objectArray .length , String [].class );
249
+
250
+ int [] arrayOfParsedOptions = new int [stringArray .length ];
251
+ int i = 0 ;
252
+ for (String option : stringArray ) {
253
+ switch (option ) {
254
+ case EMAIL_FIELD_HIDDEN :
255
+ arrayOfParsedOptions [i ++] = InvocationOption .EMAIL_FIELD_HIDDEN ;
256
+ break ;
257
+ case EMAIL_FIELD_OPTIONAL :
258
+ arrayOfParsedOptions [i ++] = InvocationOption .EMAIL_FIELD_OPTIONAL ;
259
+ break ;
260
+ case COMMENT_FIELD_REQUIRED :
261
+ arrayOfParsedOptions [i ++] = InvocationOption .COMMENT_FIELD_REQUIRED ;
262
+ break ;
263
+ case DISABLE_POST_SENDING_DIALOG :
264
+ arrayOfParsedOptions [i ++] = InvocationOption .DISABLE_POST_SENDING_DIALOG ;
265
+ break ;
266
+ default :
267
+ break ;
268
+ }
245
269
}
270
+ Log .d ("where is" , Arrays .toString (stringArray ) + " " + Arrays .toString (arrayOfParsedOptions ));
246
271
247
272
try {
248
- mInstabug .invoke (mode );
273
+ BugReporting .invoke (mode , arrayOfParsedOptions );
249
274
} catch (Exception e ) {
250
275
e .printStackTrace ();
251
276
}
0 commit comments