Skip to content

Commit 89e6603

Browse files
authored
Merge pull request #16 from revopush/expo
Expo integration
2 parents 25dde87 + 2d7e55d commit 89e6603

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ We try our best to maintain backwards compatibility of our plugin with previous
5050
| React Native version(s) | Supporting CodePush version(s) |
5151
|-------------------------|---------------------------------------------------------------------------------------------|
5252
| <v0.76 | Use [microsoft/code-push-react-native](https://github.com/microsoft/react-native-code-push) |
53-
| v0.76, v0.77, 0.78 | v1.0+ *(Support both New and Old Architectures)* |
53+
| 0.76, 0.77, 0.78, 0.79 | v1.0+ *(Support both New and Old Architectures)* |
54+
| v0.80 | v1.2 |
55+
| Expo sdk 52 | v1.3 |
5456

5557

5658
We work hard to respond to new RN releases, but they do occasionally break us. We will update this chart with each RN release, so that users can check to see what our "official" support is.

android/app/src/main/java/com/microsoft/codepush/react/CodePushNativeModule.java

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,11 @@ private void setJSBundle(ReactHostDelegate reactHostDelegate, String latestJSBun
152152
Field bundleLoaderField = reactHostDelegate.getClass().getDeclaredField("jsBundleLoader");
153153
bundleLoaderField.setAccessible(true);
154154
bundleLoaderField.set(reactHostDelegate, latestJSBundleLoader);
155-
} catch (Exception e) {
155+
}
156+
catch (NoSuchFieldException noSuchFileFound) {
157+
// Ignore this error for Expo
158+
}
159+
catch (Exception e) {
156160
CodePushUtils.log("Unable to set JSBundle of ReactHostDelegate - CodePush may not support this version of React Native");
157161
throw new IllegalAccessException("Could not setJSBundle");
158162
}
@@ -182,13 +186,23 @@ private void loadBundle() {
182186
// logic to reload the current React context.
183187
final ReactHost reactHost = resolveReactHost();
184188
if (reactHost == null) {
189+
loadBundleLegacy();
185190
return;
186191
}
187192

188193
String latestJSBundleFile = mCodePush.getJSBundleFileInternal(mCodePush.getAssetsBundleFileName());
189194

190-
// #2) Update the locally stored JS bundle file path
191-
setJSBundle(getReactHostDelegate((ReactHostImpl) reactHost), latestJSBundleFile);
195+
try {
196+
if (reactHost instanceof ReactHostImpl) {
197+
ReactHostDelegate delegate = getReactHostDelegate((ReactHostImpl) reactHost);
198+
if (delegate != null) {
199+
// #2) Update the locally stored JS bundle file path
200+
setJSBundle(delegate, latestJSBundleFile);
201+
}
202+
}
203+
} catch (Exception e) {
204+
CodePushUtils.log("Exception setJSBundle: " + e.getMessage());
205+
}
192206

193207
// #3) Get the context creation method
194208
try {

0 commit comments

Comments
 (0)