|
11 | 11 | import com.facebook.react.bridge.JavaScriptModule;
|
12 | 12 | import com.facebook.react.bridge.NativeModule;
|
13 | 13 | import com.facebook.react.bridge.ReactApplicationContext;
|
| 14 | +import com.facebook.react.devsupport.DevInternalSettings; |
| 15 | +import com.facebook.react.devsupport.interfaces.DevSupportManager; |
14 | 16 | import com.facebook.react.uimanager.ViewManager;
|
15 | 17 |
|
16 | 18 | import org.json.JSONException;
|
@@ -76,7 +78,7 @@ public CodePush(String deploymentKey, Context context, boolean isDebugMode) {
|
76 | 78 |
|
77 | 79 | mCurrentInstance = this;
|
78 | 80 |
|
79 |
| - clearDebugCacheIfNeeded(); |
| 81 | + clearDebugCacheIfNeeded(null); |
80 | 82 | initializeUpdateAfterRestart();
|
81 | 83 | }
|
82 | 84 |
|
@@ -119,8 +121,20 @@ private String getPublicKeyByResourceDescriptor(int publicKeyResourceDescriptor)
|
119 | 121 | return publicKey;
|
120 | 122 | }
|
121 | 123 |
|
122 |
| - public void clearDebugCacheIfNeeded() { |
123 |
| - if (mIsDebugMode && mSettingsManager.isPendingUpdate(null)) { |
| 124 | + public void clearDebugCacheIfNeeded(ReactInstanceManager instanceManager) { |
| 125 | + boolean isLiveReloadEnabled = false; |
| 126 | + |
| 127 | + // Use instanceManager for checking if we use LiveRelaod mode. In this case we should not remove ReactNativeDevBundle.js file |
| 128 | + // because we get error with trying to get this after reloading. Issue: https://github.com/Microsoft/react-native-code-push/issues/1272 |
| 129 | + if (instanceManager != null) { |
| 130 | + DevSupportManager devSupportManager = instanceManager.getDevSupportManager(); |
| 131 | + if (devSupportManager != null) { |
| 132 | + DevInternalSettings devInternalSettings = (DevInternalSettings)devSupportManager.getDevSettings(); |
| 133 | + isLiveReloadEnabled = devInternalSettings.isReloadOnJSChangeEnabled(); |
| 134 | + } |
| 135 | + } |
| 136 | + |
| 137 | + if (mIsDebugMode && mSettingsManager.isPendingUpdate(null) && !isLiveReloadEnabled) { |
124 | 138 | // This needs to be kept in sync with https://github.com/facebook/react-native/blob/master/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManager.java#L78
|
125 | 139 | File cachedDevBundle = new File(mContext.getFilesDir(), "ReactNativeDevBundle.js");
|
126 | 140 | if (cachedDevBundle.exists()) {
|
|
0 commit comments