Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit d9a85c8

Browse files
author
Richard Hua
authored
Support React Native 0.36.0 and 0.37.0 (#602)
* Upgrade example app to [email protected] * Fix crash on restart caused by loadBundle() being called twice
1 parent 3ccfa67 commit d9a85c8

File tree

5 files changed

+14
-18
lines changed

5 files changed

+14
-18
lines changed

Examples/CodePushDemoApp/.flowconfig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ suppress_type=$FlowIssue
4848
suppress_type=$FlowFixMe
4949
suppress_type=$FixMe
5050

51-
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(3[0-2]\\|[1-2][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
52-
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(3[0-2]\\|1[0-9]\\|[1-2][0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
51+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(3[0-3]\\|[1-2][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
52+
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(3[0-3]\\|1[0-9]\\|[1-2][0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
5353
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
5454

5555
unsafe.enable_getters_and_setters=true
5656

5757
[version]
58-
^0.32.0
58+
^0.33.0

Examples/CodePushDemoApp/android/app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,6 @@ dependencies {
136136
// Run this once to be able to run the application with BUCK
137137
// puts all compile dependencies into folder libs for BUCK to use
138138
task copyDownloadableDepsToLibs(type: Copy) {
139-
from configurations.compile
140-
into 'libs'
139+
from configurations.compile
140+
into 'libs'
141141
}

Examples/CodePushDemoApp/iOS/CodePushDemoApp/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
<dict>
4646
<key>localhost</key>
4747
<dict>
48-
<key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
48+
<key>NSExceptionAllowsInsecureHTTPLoads</key>
4949
<true/>
5050
</dict>
5151
</dict>

Examples/CodePushDemoApp/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"dependencies": {
99
"babel-preset-react-native-stage-0": "1.0.1",
1010
"react": "15.3.1",
11-
"react-native": "0.35.0",
11+
"react-native": "0.37.0",
1212
"react-native-code-push": "file:../../"
1313
}
1414
}

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

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -451,17 +451,13 @@ protected Void doInBackground(Void... params) {
451451

452452
@Override
453453
public void onHostResume() {
454-
if (installMode == CodePushInstallMode.IMMEDIATE.getValue()) {
455-
loadBundle();
456-
} else {
457-
// Determine how long the app was in the background and ensure
458-
// that it meets the minimum duration amount of time.
459-
long durationInBackground = 0;
460-
if (lastPausedDate != null) {
461-
durationInBackground = (new Date().getTime() - lastPausedDate.getTime()) / 1000;
462-
}
463-
464-
if (durationInBackground >= CodePushNativeModule.this.mMinimumBackgroundDuration) {
454+
// As of RN 36, the resume handler fires immediately if the app is in
455+
// the foreground, so explicitly wait for it to be backgrounded first
456+
if (lastPausedDate != null) {
457+
long durationInBackground = (new Date().getTime() - lastPausedDate.getTime()) / 1000;
458+
if (installMode == CodePushInstallMode.IMMEDIATE.getValue()
459+
|| durationInBackground >= CodePushNativeModule.this.mMinimumBackgroundDuration) {
460+
CodePushUtils.log("Loading bundle on resume");
465461
loadBundle();
466462
}
467463
}

0 commit comments

Comments
 (0)