@@ -136,9 +136,9 @@ public static RNCallKeepModule getInstance(ReactApplicationContext reactContext,
136136 return instance ;
137137 }
138138
139- public static WritableMap getSettings () {
139+ public static WritableMap getSettings (@ Nullable Context context ) {
140140 if (_settings == null ) {
141- fetchStoredSettings ();
141+ fetchStoredSettings (context );
142142 }
143143
144144 return _settings ;
@@ -222,7 +222,7 @@ public void setSettings(ReadableMap options) {
222222 Log .d (TAG , "[RNCallKeepModule] setSettings: " + options );
223223 storeSettings (options );
224224
225- _settings = getSettings ();
225+ _settings = getSettings (null );
226226 }
227227
228228 @ ReactMethod
@@ -770,7 +770,7 @@ public void setForegroundServiceSettings(ReadableMap foregroundServerSettings) {
770770 }
771771
772772 // Retrieve settings and set the `foregroundService` value
773- WritableMap settings = getSettings ();
773+ WritableMap settings = getSettings (null );
774774 if (settings != null ) {
775775 settings .putMap ("foregroundService" , MapUtils .readableToWritableMap (foregroundServerSettings ));
776776 }
@@ -1036,11 +1036,12 @@ private void storeSettings(ReadableMap options) {
10361036 }
10371037 }
10381038
1039- private static void fetchStoredSettings () {
1040- if (instance == null ) {
1039+ private static void fetchStoredSettings (@ Nullable Context fromContext ) {
1040+ if (instance == null && fromContext == null ) {
1041+ Log .w (TAG , "[RNCallKeepModule][fetchStoredSettings] no instance nor fromContext." );
10411042 return ;
10421043 }
1043- Context context = instance .getAppContext ();
1044+ Context context = fromContext != null ? fromContext : instance .getAppContext ();
10441045 _settings = new WritableNativeMap ();
10451046 if (context == null ) {
10461047 Log .w (TAG , "[RNCallKeepModule][fetchStoredSettings] no react context found." );
0 commit comments