Skip to content

Commit

Permalink
[FFM-10442] - Disable streaming if Reactive Native + Android is detected
Browse files Browse the repository at this point in the history
What
Make the JS SDK fall back to polling when it detects that it is running inside Android on React native

Why
XMLHttpRequest does not work correctly on React Native when Android is used.
For more context: facebook/react-native#28835
We will use this work around until a better fix is identified.

Testing
Manual
  • Loading branch information
andybharness committed Feb 20, 2024
1 parent fc679ab commit 72d4be3
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,19 @@ const initialize = (apiKey: string, target: Target, options?: Options): Result =
configurations.pollingInterval = MIN_POLLING_INTERVAL
}

if (configurations.streamEnabled) {
try {
const { Platform } = require("react-native");
if (Platform.OS === 'android') {
console.warn("SDKCODE:1007 workaround applied - Android React Native detected - streaming will be disabled and polling enabled")
configurations.pollingEnabled = true
configurations.streamEnabled = false
}
} catch (e) {
// ignore
}
}

const logDebug = (message: string, ...args: any[]) => {
if (configurations.debug) {
// tslint:disable-next-line:no-console
Expand Down

0 comments on commit 72d4be3

Please sign in to comment.