Skip to content

Commit

Permalink
Merge pull request #19133 from Expensify/Rory-PingAuth
Browse files Browse the repository at this point in the history
[No QA] Configure NetInfo to ping auth for reachability
  • Loading branch information
Joel Bettner authored May 20, 2023
2 parents 75835a9 + c979bf5 commit 7378626
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 11 deletions.
8 changes: 4 additions & 4 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ PODS:
- React-Core
- react-native-key-command (1.0.0):
- React-Core
- react-native-netinfo (8.3.1):
- react-native-netinfo (9.3.10):
- React-Core
- react-native-pdf (6.6.2):
- React-Core
Expand Down Expand Up @@ -1067,7 +1067,7 @@ SPEC CHECKSUMS:
RCTTypeSafety: 9ae0e9206625e995f0df4d5b9ddc94411929fb30
React: a71c8e1380f07e01de721ccd52bcf9c03e81867d
React-callinvoker: fc9f36c92c287c012d3fb45ea0f1b523c4f5aaa8
React-Codegen: 7dcbda38b5b38a9354ef0ef00c420d6921d7bbb7
React-Codegen: 47ad49a58fd95a9560a25f6054ee8984ff3afadb
React-Core: aab8ea7f615a86b3a73ce87aa9be4c563e49648b
React-CoreModules: f2a86b01c227e0137c83c13dd645fe69270cef80
React-cxxreact: 8adcafaeb0f02ae1282698c482ffa4c73fca4a35
Expand All @@ -1085,7 +1085,7 @@ SPEC CHECKSUMS:
react-native-image-manipulator: c48f64221cfcd46e9eec53619c4c0374f3328a56
react-native-image-picker: c33d4e79f0a14a2b66e5065e14946ae63749660b
react-native-key-command: 0b3aa7c9f5c052116413e81dce33a3b2153a6c5d
react-native-netinfo: 1a6035d3b9780221d407c277ebfb5722ace00658
react-native-netinfo: ccbe1085dffd16592791d550189772e13bf479e2
react-native-pdf: 33c622cbdf776a649929e8b9d1ce2d313347c4fa
react-native-performance: 224bd53e6a835fda4353302cf891d088a0af7406
react-native-plaid-link-sdk: 9eb0f71dad94b3bdde649c7a384cba93024af46c
Expand Down Expand Up @@ -1135,4 +1135,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: 4ed1c7b099741c82e2b0411b95f6468e72be6c76

COCOAPODS: 1.12.0
COCOAPODS: 1.12.1
11 changes: 7 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"@react-native-camera-roll/camera-roll": "5.4.0",
"@react-native-community/clipboard": "^1.5.1",
"@react-native-community/datetimepicker": "^3.5.2",
"@react-native-community/netinfo": "^8.3.0",
"@react-native-community/netinfo": "^9.3.10",
"@react-native-community/progress-bar-android": "^1.0.4",
"@react-native-community/progress-view": "^1.2.3",
"@react-native-firebase/analytics": "^12.3.0",
Expand Down
13 changes: 11 additions & 2 deletions src/libs/NetworkConnection.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,17 @@ function subscribeToNetInfo() {
// By default, NetInfo uses `/` for `reachabilityUrl`
// When App is served locally (or from Electron) this address is always reachable - even offline
// Using the API url ensures reachability is tested over internet
reachabilityUrl: `${CONFIG.EXPENSIFY.DEFAULT_API_ROOT}api`,
reachabilityTest: (response) => Promise.resolve(response.status === 200),
reachabilityUrl: `${CONFIG.EXPENSIFY.DEFAULT_API_ROOT}api?command=Ping`,
reachabilityMethod: 'GET',
reachabilityTest: (response) => {
if (!response.ok) {
return Promise.resolve(false);
}
return response
.json()
.then((json) => Promise.resolve(json.jsonCode === 200))
.catch(() => Promise.resolve(false));
},

// If a check is taking longer than this time we're considered offline
reachabilityRequestTimeout: CONST.NETWORK.MAX_PENDING_TIME_MS,
Expand Down

0 comments on commit 7378626

Please sign in to comment.