@@ -74,7 +74,7 @@ public String toString(){
7474public class CountlyReactNative extends ReactContextBaseJavaModule implements LifecycleEventListener {
7575
7676 public static final String TAG = "CountlyRNPlugin" ;
77- private String COUNTLY_RN_SDK_VERSION_STRING = "20.11.8 " ;
77+ private String COUNTLY_RN_SDK_VERSION_STRING = "20.11.9 " ;
7878 private String COUNTLY_RN_SDK_NAME = "js-rnb-android" ;
7979
8080 private static CountlyConfig config = new CountlyConfig ();
@@ -86,6 +86,7 @@ public class CountlyReactNative extends ReactContextBaseJavaModule implements Li
8686 protected static boolean loggingEnabled = false ;
8787
8888 private boolean isOnResumeBeforeInit = false ;
89+ private Boolean isSessionStarted_ = false ;
8990
9091 private ReactApplicationContext _reactContext ;
9192
@@ -562,16 +563,26 @@ public void onComplete(Task<InstanceIdResult> task) {
562563
563564 @ ReactMethod
564565 public void start (){
566+ if (isSessionStarted_ ) {
567+ log ("session already started" , LogLevel .INFO );
568+ return ;
569+ }
565570 Activity activity = this .getActivity ();
566571 if (activity == null ) {
567572 log ("While calling 'start', Activity is null" , LogLevel .WARNING );
568573 }
569574 Countly .sharedInstance ().onStart (activity );
575+ isSessionStarted_ = true ;
570576 }
571577
572578 @ ReactMethod
573579 public void stop (){
580+ if (!isSessionStarted_ ) {
581+ log ("must call Start before Stop" , LogLevel .INFO );
582+ return ;
583+ }
574584 Countly .sharedInstance ().onStop ();
585+ isSessionStarted_ = false ;
575586 }
576587
577588 @ ReactMethod
@@ -1071,6 +1082,10 @@ Activity getActivity() {
10711082 @ Override
10721083 public void onHostResume () {
10731084 if (Countly .sharedInstance ().isInitialized ()) {
1085+ if (isSessionStarted_ ) {
1086+ Activity activity = getActivity ();
1087+ Countly .sharedInstance ().onStart (activity );
1088+ }
10741089 Countly .sharedInstance ().apm ().triggerForeground ();
10751090 }
10761091 else {
@@ -1081,6 +1096,9 @@ public void onHostResume() {
10811096 @ Override
10821097 public void onHostPause () {
10831098 if (Countly .sharedInstance ().isInitialized ()) {
1099+ if (isSessionStarted_ ) {
1100+ Countly .sharedInstance ().onStop ();
1101+ }
10841102 Countly .sharedInstance ().apm ().triggerBackground ();
10851103 }
10861104 }
0 commit comments