react-native-gleapsdk 6.4.5-beta.1 → 7.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,21 +1,3 @@
1
- MIT License
1
+ Copyright (C) 2020 by Gleap GmbH. Permission is hereby granted to use this framework as is, modification are not allowed. All rights reserved.
2
2
 
3
- Copyright (c) 2021 gleap
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
3
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. FURTHER RESELLING OF THE SDK OR IT'S CODE IS ONLY GRANTED WITH A WRITTEN PERMISSION BY GLEAP GMBH.
@@ -54,7 +54,6 @@ repositories {
54
54
 
55
55
  dependencies {
56
56
  //noinspection GradleDynamicVersion
57
- implementation "com.facebook.react:react-native:+" // From node_modules
58
- // https://mvnrepository.com/artifact/io.gleap/gleap-android-sdk
59
- implementation group: 'io.gleap', name: 'gleap-android-sdk', version: '6.4.11-hotfix'
57
+ implementation "com.facebook.react:react-native:+"
58
+ implementation group: 'io.gleap', name: 'gleap-android-sdk', version: '7.0.10'
60
59
  }
@@ -26,20 +26,25 @@ import java.io.FileOutputStream;
26
26
  import java.io.OutputStream;
27
27
  import java.util.ArrayList;
28
28
  import java.util.Base64;
29
+ import java.util.logging.Logger;
29
30
  import java.util.regex.Matcher;
30
31
  import java.util.regex.Pattern;
31
32
 
32
33
  import io.gleap.APPLICATIONTYPE;
33
- import io.gleap.ConfigLoadedCallback;
34
- import io.gleap.CustomActionCallback;
35
- import io.gleap.FeedbackSentCallback;
36
- import io.gleap.FeedbackSentWithDataCallback;
37
- import io.gleap.FeedbackWillBeSentCallback;
38
- import io.gleap.GetActivityCallback;
39
34
  import io.gleap.Gleap;
40
35
  import io.gleap.GleapActivationMethod;
41
36
  import io.gleap.GleapUserProperties;
37
+ import io.gleap.PrefillHelper;
42
38
  import io.gleap.RequestType;
39
+ import io.gleap.UserSessionController;
40
+ import io.gleap.callbacks.ConfigLoadedCallback;
41
+ import io.gleap.callbacks.CustomActionCallback;
42
+ import io.gleap.callbacks.FeedbackFlowStartedCallback;
43
+ import io.gleap.callbacks.FeedbackSendingFailedCallback;
44
+ import io.gleap.callbacks.FeedbackSentCallback;
45
+ import io.gleap.callbacks.GetActivityCallback;
46
+ import io.gleap.callbacks.WidgetClosedCallback;
47
+ import io.gleap.callbacks.WidgetOpenedCallback;
43
48
 
44
49
  @ReactModule(name = GleapsdkModule.NAME)
45
50
  public class GleapsdkModule extends ReactContextBaseJavaModule implements LifecycleEventListener {
@@ -47,16 +52,18 @@ public class GleapsdkModule extends ReactContextBaseJavaModule implements Lifecy
47
52
  private boolean isSilentBugReport = false;
48
53
  private boolean invalidated = false;
49
54
 
50
- public GleapsdkModule(ReactApplicationContext reactContext) {
51
- super(reactContext);
55
+ public GleapsdkModule(ReactApplicationContext context) {
56
+ super(context);
52
57
  Gleap.getInstance().setGetActivityCallback(new GetActivityCallback() {
53
58
  @Override
54
59
  public Activity getActivity() {
55
- return reactContext.getCurrentActivity();
60
+ return context.getCurrentActivity();
56
61
  }
57
62
  });
63
+
58
64
  }
59
65
 
66
+
60
67
  @Override
61
68
  @NonNull
62
69
  public String getName() {
@@ -70,36 +77,60 @@ public class GleapsdkModule extends ReactContextBaseJavaModule implements Lifecy
70
77
  */
71
78
  @ReactMethod
72
79
  public void initialize(String sdkKey) {
73
- getCurrentActivity().runOnUiThread(
80
+ try {
81
+ getActivitySafe().runOnUiThread(
74
82
  new Runnable() {
75
83
  @Override
76
84
  public void run() {
77
85
  try {
78
86
  Activity activity = getReactApplicationContext()
79
- .getCurrentActivity();
87
+ .getCurrentActivity();
80
88
  if (activity != null && !invalidated) {
81
89
  Gleap.getInstance().setApplicationType(APPLICATIONTYPE.REACTNATIVE);
82
- Gleap.getInstance().setFeedbackWillBeSentCallback(new FeedbackWillBeSentCallback() {
90
+ Gleap.initialize(sdkKey, activity.getApplication());
91
+
92
+ Gleap.getInstance().setWidgetOpenedCallback(new WidgetOpenedCallback() {
83
93
  @Override
84
- public void flowInvoced() {
85
- if (!invalidated) {
86
- getReactApplicationContext().getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
87
- .emit("feedbackWillBeSent", null);
88
- }
94
+ public void invoke() {
95
+ getReactApplicationContext().getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
96
+ .emit("widgetOpened", null);
97
+ }
98
+ });
99
+
100
+ Gleap.getInstance().setWidgetClosedCallback(new WidgetClosedCallback() {
101
+ @Override
102
+ public void invoke() {
103
+ getReactApplicationContext().getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
104
+ .emit("widgetClosed", null);
89
105
  }
90
106
  });
91
107
 
92
- Gleap.initialize(sdkKey, activity.getApplication());
93
108
  Gleap.getInstance().setConfigLoadedCallback(new ConfigLoadedCallback() {
94
109
  @Override
95
110
  public void configLoaded(JSONObject jsonObject) {
96
111
  if (!invalidated) {
97
112
  getReactApplicationContext().getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
98
- .emit("configLoaded", jsonObject.toString());
113
+ .emit("configLoaded", jsonObject.toString());
99
114
  }
100
115
  }
101
116
  });
102
117
 
118
+ Gleap.getInstance().setFeedbackSentCallback(new FeedbackSentCallback() {
119
+ @Override
120
+ public void invoke(String message) {
121
+ getReactApplicationContext().getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
122
+ .emit("feedbackSent", message);
123
+ }
124
+ });
125
+
126
+ Gleap.getInstance().setFeedbackSendingFailedCallback(new FeedbackSendingFailedCallback() {
127
+ @Override
128
+ public void invoke(String message) {
129
+ getReactApplicationContext().getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
130
+ .emit("feedbackSendingFailed", message);
131
+ }
132
+ });
133
+
103
134
  Gleap.getInstance().registerCustomAction(new CustomActionCallback() {
104
135
  @Override
105
136
  public void invoke(String message) {
@@ -111,38 +142,16 @@ public class GleapsdkModule extends ReactContextBaseJavaModule implements Lifecy
111
142
  }
112
143
  if (!invalidated) {
113
144
  getReactApplicationContext().getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
114
- .emit("customActionTriggered", obj.toString());
145
+ .emit("customActionTriggered", obj.toString());
115
146
  }
116
147
  }
117
148
  });
118
149
 
119
- Gleap.getInstance().setFeedbackSentWithDataCallback(new FeedbackSentWithDataCallback() {
150
+ Gleap.getInstance().setFeedbackFlowStartedCallback(new FeedbackFlowStartedCallback() {
120
151
  @Override
121
- public void close(JSONObject jsonObject) {
152
+ public void invoke(String message) {
122
153
  getReactApplicationContext().getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
123
- .emit("feedbackSent", jsonObject.toString());
124
- new java.util.Timer().schedule(
125
- new java.util.TimerTask() {
126
- @Override
127
- public void run() {
128
- showDevMenu();
129
- }
130
- },
131
- 500);
132
- }
133
- });
134
-
135
- Gleap.getInstance().setFeedbackSentCallback(new FeedbackSentCallback() {
136
- @Override
137
- public void close() {
138
- new java.util.Timer().schedule(
139
- new java.util.TimerTask() {
140
- @Override
141
- public void run() {
142
- showDevMenu();
143
- }
144
- },
145
- 500);
154
+ .emit("feedbackFlowStarted", message);
146
155
  }
147
156
  });
148
157
  }
@@ -151,6 +160,9 @@ public class GleapsdkModule extends ReactContextBaseJavaModule implements Lifecy
151
160
  }
152
161
  }
153
162
  });
163
+ } catch (NoUiThreadException e) {
164
+ System.err.println(e.getMessage());
165
+ }
154
166
  }
155
167
 
156
168
  @ReactMethod
@@ -168,27 +180,28 @@ public class GleapsdkModule extends ReactContextBaseJavaModule implements Lifecy
168
180
  */
169
181
  @ReactMethod
170
182
  public void open() {
171
- getCurrentActivity().runOnUiThread(
183
+ try {
184
+ getActivitySafe().runOnUiThread(
172
185
  new Runnable() {
173
186
  @Override
174
187
  public void run() {
175
188
  try {
176
- Gleap.getInstance().startFeedbackFlow();
189
+ Gleap.getInstance().open();
177
190
  Gleap.getInstance().setFeedbackSentCallback(new FeedbackSentCallback() {
178
191
  @Override
179
- public void close() {
192
+ public void invoke(String message) {
180
193
  new java.util.Timer().schedule(
181
- new java.util.TimerTask() {
182
- @Override
183
- public void run() {
184
- if (!isSilentBugReport) {
185
- showDevMenu();
186
- } else {
187
- isSilentBugReport = false;
188
- }
194
+ new java.util.TimerTask() {
195
+ @Override
196
+ public void run() {
197
+ if (!isSilentBugReport) {
198
+ showDevMenu();
199
+ } else {
200
+ isSilentBugReport = false;
189
201
  }
190
- },
191
- 500);
202
+ }
203
+ },
204
+ 500);
192
205
  }
193
206
  });
194
207
  } catch (Exception e) {
@@ -196,34 +209,70 @@ public class GleapsdkModule extends ReactContextBaseJavaModule implements Lifecy
196
209
  }
197
210
  }
198
211
  });
212
+ } catch (NoUiThreadException e) {
213
+ System.err.println(e.getMessage());
214
+ }
215
+ }
216
+
217
+ @ReactMethod
218
+ public void close() {
219
+ try {
220
+ getActivitySafe().runOnUiThread(
221
+ new Runnable() {
222
+ @Override
223
+ public void run() {
224
+ try {
225
+ Gleap.getInstance().close();
226
+ }catch (Exception ex) {}
227
+ }
228
+ });
229
+ } catch (NoUiThreadException e) {
230
+ System.err.println(e.getMessage());
231
+ }
232
+ }
233
+
234
+ @ReactMethod
235
+ public void isOpened() {
236
+ try {
237
+ getActivitySafe().runOnUiThread(
238
+ new Runnable() {
239
+ @Override
240
+ public void run() {
241
+ Gleap.getInstance().isOpened();
242
+ }
243
+ });
244
+ } catch (NoUiThreadException e) {
245
+ System.err.println(e.getMessage());
246
+ }
199
247
  }
200
248
 
201
249
  /**
202
250
  * Start bug report manually by calling this function.
203
251
  */
204
252
  @ReactMethod
205
- public void startFeedbackFlow(String feedbackFlow) {
206
- getCurrentActivity().runOnUiThread(
253
+ public void startFeedbackFlow(String feedbackFlow, boolean showBackButton) {
254
+ try {
255
+ getActivitySafe().runOnUiThread(
207
256
  new Runnable() {
208
257
  @Override
209
258
  public void run() {
210
259
  try {
211
- Gleap.getInstance().startFeedbackFlow(feedbackFlow);
260
+ Gleap.getInstance().startFeedbackFlow(feedbackFlow, showBackButton);
212
261
  Gleap.getInstance().setFeedbackSentCallback(new FeedbackSentCallback() {
213
262
  @Override
214
- public void close() {
263
+ public void invoke(String message) {
215
264
  new java.util.Timer().schedule(
216
- new java.util.TimerTask() {
217
- @Override
218
- public void run() {
219
- if (!isSilentBugReport) {
220
- showDevMenu();
221
- } else {
222
- isSilentBugReport = false;
223
- }
265
+ new java.util.TimerTask() {
266
+ @Override
267
+ public void run() {
268
+ if (!isSilentBugReport) {
269
+ showDevMenu();
270
+ } else {
271
+ isSilentBugReport = false;
224
272
  }
225
- },
226
- 500);
273
+ }
274
+ },
275
+ 500);
227
276
  }
228
277
  });
229
278
  } catch (Exception e) {
@@ -231,16 +280,20 @@ public class GleapsdkModule extends ReactContextBaseJavaModule implements Lifecy
231
280
  }
232
281
  }
233
282
  });
283
+ } catch (NoUiThreadException e) {
284
+ System.err.println(e.getMessage());
285
+ }
234
286
  }
235
287
 
236
288
  /**
237
289
  * Manually start a silent bug reporting workflow.
238
290
  */
239
291
  @ReactMethod
240
- public void sendSilentBugReport(
241
- String description,
242
- String priority) {
243
- getCurrentActivity().runOnUiThread(
292
+ public void sendSilentCrashReport(
293
+ String description,
294
+ String priority) {
295
+ try {
296
+ getActivitySafe().runOnUiThread(
244
297
  new Runnable() {
245
298
  @Override
246
299
  public void run() {
@@ -252,23 +305,33 @@ public class GleapsdkModule extends ReactContextBaseJavaModule implements Lifecy
252
305
  if (priority == "HIGH") {
253
306
  severity = Gleap.SEVERITY.HIGH;
254
307
  }
255
- Gleap.getInstance().sendSilentBugReport(description, severity);
308
+ Gleap.getInstance().sendSilentCrashReport(description, severity);
256
309
  }
257
310
  });
311
+ } catch (NoUiThreadException e) {
312
+ System.err.println(e.getMessage());
313
+ }
258
314
  }
259
315
 
260
316
  /**
261
317
  * Manually start a silent bug reporting workflow.
262
318
  */
263
319
  @ReactMethod
264
- public void sendSilentBugReportWithType(
265
- String description,
266
- String priority,
267
- String type) {
268
- getCurrentActivity().runOnUiThread(
320
+ public void sendSilentCrashReportWithExcludeData(
321
+ String description,
322
+ String priority,
323
+ ReadableMap data) {
324
+ try {
325
+ getActivitySafe().runOnUiThread(
269
326
  new Runnable() {
270
327
  @Override
271
328
  public void run() {
329
+ JSONObject jsonObject = new JSONObject();
330
+ try {
331
+ jsonObject = GleapUtil.convertMapToJson(data);
332
+ } catch (Exception ex) {
333
+ }
334
+
272
335
  isSilentBugReport = true;
273
336
  Gleap.SEVERITY severity = Gleap.SEVERITY.LOW;
274
337
  if (priority == "MEDIUM") {
@@ -277,11 +340,36 @@ public class GleapsdkModule extends ReactContextBaseJavaModule implements Lifecy
277
340
  if (priority == "HIGH") {
278
341
  severity = Gleap.SEVERITY.HIGH;
279
342
  }
280
- Gleap.getInstance().sendSilentBugReport(description, severity, type);
343
+ Gleap.getInstance().sendSilentCrashReport(description, severity, jsonObject);
344
+ }
345
+ });
346
+ } catch (NoUiThreadException e) {
347
+ System.err.println(e.getMessage());
348
+ }
349
+ }
350
+
351
+ @ReactMethod
352
+ public void preFillForm(
353
+ ReadableMap data) {
354
+ try {
355
+ getActivitySafe().runOnUiThread(
356
+ new Runnable() {
357
+ @Override
358
+ public void run() {
359
+ JSONObject jsonObject = new JSONObject();
360
+ try {
361
+ jsonObject = GleapUtil.convertMapToJson(data);
362
+ } catch (Exception ex) {
363
+ }
364
+ PrefillHelper.getInstancen().setPrefillData(jsonObject);
281
365
  }
282
366
  });
367
+ } catch (NoUiThreadException e) {
368
+ System.err.println(e.getMessage());
369
+ }
283
370
  }
284
371
 
372
+
285
373
  @ReactMethod
286
374
  public void setLanguage(String language) {
287
375
  Gleap.getInstance().setLanguage(language);
@@ -289,11 +377,13 @@ public class GleapsdkModule extends ReactContextBaseJavaModule implements Lifecy
289
377
 
290
378
  @ReactMethod
291
379
  public void enableDebugConsoleLog() {
380
+
292
381
  }
293
382
 
294
383
  @ReactMethod
295
384
  public void identify(String userid, ReadableMap data) {
296
- getCurrentActivity().runOnUiThread(
385
+ try {
386
+ getActivitySafe().runOnUiThread(
297
387
  new Runnable() {
298
388
  @Override
299
389
  public void run() {
@@ -312,14 +402,67 @@ public class GleapsdkModule extends ReactContextBaseJavaModule implements Lifecy
312
402
  e.printStackTrace();
313
403
  }
314
404
  GleapUserProperties gleapUserSession = new GleapUserProperties(name, email);
405
+ if (Gleap.getInstance() == null) {
406
+ return;
407
+ }
315
408
  Gleap.getInstance().identifyUser(userid, gleapUserSession);
316
409
  }
317
410
  });
411
+ } catch (NoUiThreadException e) {
412
+ System.err.println(e.getMessage());
413
+ }
414
+ }
415
+
416
+ @ReactMethod
417
+ public void identifyWithUserHash(String userid, ReadableMap data, String hash) {
418
+ try {
419
+ getActivitySafe().runOnUiThread(
420
+ new Runnable() {
421
+ @Override
422
+ public void run() {
423
+ JSONObject jsonObject = null;
424
+ String name = "";
425
+ String email = "";
426
+ try {
427
+ jsonObject = GleapUtil.convertMapToJson(data);
428
+ if (jsonObject.has("name")) {
429
+ name = jsonObject.getString("name");
430
+ }
431
+ if (jsonObject.has("email")) {
432
+ email = jsonObject.getString("email");
433
+ }
434
+ } catch (JSONException e) {
435
+ e.printStackTrace();
436
+ }
437
+ GleapUserProperties gleapUserSession = new GleapUserProperties(name, email);
438
+ gleapUserSession.setHash(hash);
439
+ if (Gleap.getInstance() == null) {
440
+ return;
441
+ }
442
+
443
+ if (UserSessionController.getInstance() != null) {
444
+ Gleap.getInstance().identifyUser(userid, gleapUserSession);
445
+ }
446
+ }
447
+ });
448
+ } catch (NoUiThreadException e) {
449
+ System.err.println(e.getMessage());
450
+ }
318
451
  }
319
452
 
320
453
  @ReactMethod
321
454
  public void clearIdentity() {
322
- Gleap.getInstance().clearIdentity();
455
+ try {
456
+ getActivitySafe().runOnUiThread(
457
+ new Runnable() {
458
+ @Override
459
+ public void run() {
460
+ Gleap.getInstance().clearIdentity();
461
+ }
462
+ });
463
+ } catch (NoUiThreadException e) {
464
+ System.err.println(e.getMessage());
465
+ }
323
466
  }
324
467
 
325
468
  /**
@@ -333,7 +476,10 @@ public class GleapsdkModule extends ReactContextBaseJavaModule implements Lifecy
333
476
  public void attachCustomData(ReadableMap customData) {
334
477
  try {
335
478
  JSONObject jsonObject = GleapUtil.convertMapToJson(customData);
336
- Gleap.getInstance().appendCustomData(jsonObject);
479
+ if (Gleap.getInstance() == null) {
480
+ return;
481
+ }
482
+ Gleap.getInstance().attachCustomData(jsonObject);
337
483
  } catch (Exception e) {
338
484
  System.out.println(e);
339
485
  }
@@ -355,31 +501,15 @@ public class GleapsdkModule extends ReactContextBaseJavaModule implements Lifecy
355
501
  }
356
502
 
357
503
  /**
358
- * Used for dedicated server. Set the url, where the widget is loaded from.
504
+ * Frame url
505
+ * 330,.
359
506
  *
360
- * @param widgetUrl Url to the dedicated server.
507
+ * @param frameUrl Url to the dedicated server.
361
508
  */
362
509
  @ReactMethod
363
- public void setWidgetUrl(String widgetUrl) {
510
+ public void setFrameUrl(String frameUrl) {
364
511
  try {
365
- Gleap.getInstance().setApiUrl(widgetUrl);
366
- } catch (Exception e) {
367
- System.out.println(e);
368
- }
369
- }
370
-
371
- /**
372
- * Attaches custom data, which can be viewed in the Gleap dashboard. New data
373
- * will be merged with existing custom data.
374
- *
375
- * @param customData The data to attach to a bug report.
376
- * @author Gleap
377
- */
378
- @ReactMethod
379
- public void appendCustomData(ReadableMap customData) {
380
- try {
381
- JSONObject jsonObject = GleapUtil.convertMapToJson(customData);
382
- Gleap.getInstance().appendCustomData(jsonObject);
512
+ Gleap.getInstance().setFrameUrl(frameUrl);
383
513
  } catch (Exception e) {
384
514
  System.out.println(e);
385
515
  }
@@ -425,8 +555,10 @@ public class GleapsdkModule extends ReactContextBaseJavaModule implements Lifecy
425
555
  internalActivationMethods.add(GleapActivationMethod.SCREENSHOT);
426
556
  }
427
557
  }
428
- Gleap.getInstance().setActivationMethods(
558
+ if(Gleap.getInstance() != null) {
559
+ Gleap.getInstance().setActivationMethods(
429
560
  internalActivationMethods.toArray(new GleapActivationMethod[internalActivationMethods.size()]));
561
+ }
430
562
  }
431
563
 
432
564
  /**
@@ -454,8 +586,8 @@ public class GleapsdkModule extends ReactContextBaseJavaModule implements Lifecy
454
586
  request = (JSONObject) currentRequest.get("request");
455
587
  }
456
588
  Gleap.getInstance().logNetwork(currentRequest.getString("url"),
457
- RequestType.valueOf(currentRequest.getString("type")), response.getInt("status"),
458
- currentRequest.getInt("duration"), request, response);
589
+ RequestType.valueOf(currentRequest.getString("type")), response.getInt("status"),
590
+ currentRequest.getInt("duration"), request, response);
459
591
  }
460
592
 
461
593
  } catch (Exception ex) {
@@ -572,7 +704,7 @@ public class GleapsdkModule extends ReactContextBaseJavaModule implements Lifecy
572
704
 
573
705
  private boolean checkAllowedEndings(String fileName) {
574
706
  String[] fileType = fileName.split("\\.");
575
- String[] allowedTypes = { "jpeg", "svg", "png", "mp4", "webp", "xml", "plain", "xml", "json" };
707
+ String[] allowedTypes = {"jpeg", "svg", "png", "mp4", "webp", "xml", "plain", "xml", "json"};
576
708
  if (fileType.length <= 1) {
577
709
  return false;
578
710
  }
@@ -590,23 +722,24 @@ public class GleapsdkModule extends ReactContextBaseJavaModule implements Lifecy
590
722
  * Show dev menu after shaking the phone.
591
723
  */
592
724
  private void showDevMenu() {
593
- getCurrentActivity().runOnUiThread(
725
+ try {
726
+ getActivitySafe().runOnUiThread(
594
727
  new Runnable() {
595
728
  @Override
596
729
  public void run() {
597
730
  final ReactApplication application = (ReactApplication) getReactApplicationContext()
598
- .getCurrentActivity()
599
- .getApplication();
731
+ .getCurrentActivity()
732
+ .getApplication();
600
733
  Handler mainHandler = new Handler(GleapsdkModule.this.getReactApplicationContext().getMainLooper());
601
734
  Runnable myRunnable = new Runnable() {
602
735
  @Override
603
736
  public void run() {
604
737
  try {
605
738
  application
606
- .getReactNativeHost()
607
- .getReactInstanceManager()
608
- .getDevSupportManager()
609
- .showDevOptionsDialog();
739
+ .getReactNativeHost()
740
+ .getReactInstanceManager()
741
+ .getDevSupportManager()
742
+ .showDevOptionsDialog();
610
743
  } catch (Exception e) {
611
744
  e.printStackTrace();
612
745
  }
@@ -615,6 +748,9 @@ public class GleapsdkModule extends ReactContextBaseJavaModule implements Lifecy
615
748
  mainHandler.post(myRunnable);
616
749
  }
617
750
  });
751
+ } catch (NoUiThreadException e) {
752
+ System.err.println(e.getMessage());
753
+ }
618
754
  }
619
755
 
620
756
  @Override
@@ -640,4 +776,12 @@ public class GleapsdkModule extends ReactContextBaseJavaModule implements Lifecy
640
776
  invalidated = true;
641
777
  super.invalidate();
642
778
  }
779
+
780
+ private Activity getActivitySafe() throws NoUiThreadException {
781
+ Activity activity = getCurrentActivity();
782
+ if (activity == null) {
783
+ throw new NoUiThreadException();
784
+ }
785
+ return activity;
786
+ }
643
787
  }
@@ -0,0 +1,7 @@
1
+ package com.reactnativegleapsdk;
2
+
3
+ public class NoUiThreadException extends Exception{
4
+ public NoUiThreadException() {
5
+ super("No ui thread found. Please be careful when initialising the sdk.");
6
+ }
7
+ }