You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
DeviceEventEmitter.addListener is not working in release version, but works completely fine in the debug version of the app.
When added a adblogcat command to observe the event emission from the native code, we can see that data is emitted from the native side of the app, but fails to capture in react side.
Steps to reproduce
Add useEffect in the app.js file to listen for the event.
useEffect(function() {
let deferredLinkSubscription = null
return () => {
// Clean up the event listeners on unmount
deferredLinkSubscription?.remove?.()
}
}, [])
React Native Version
0.76.5
Affected Platforms
Runtime - Android
Output of npx react-native info
System:
OS: Windows 11 10.0.26100
CPU: (20) x64 12th Gen Intel(R) Core(TM) i7-12700H
Memory: 1.38 GB / 15.69 GB
Binaries:
Node:
version: 20.10.0
path: C:\Program Files\nodejs\node.EXE
Yarn: Not Found
npm:
version: 10.8.3
path: C:\Program Files\nodejs\npm.CMD
Watchman: Not Found
SDKs:
Android SDK:
API Levels:
- "28"
- "31"
- "33"
- "34"
- "35"
Build Tools:
- 30.0.3
- 33.0.0
- 33.0.1
- 34.0.0
- 35.0.0
System Images:
- android-33 | Google APIs Intel x86_64 Atom
- android-33 | Google Play Intel x86_64 Atom
- android-34 | Google APIs Intel x86_64 Atom
- android-34 | Google Play Intel x86_64 Atom
Android NDK: Not Found
Windows SDK: Not Found
IDEs:
Android Studio: AI-242.23339.11.2421.12550806
Visual Studio: Not Found
Languages:
Java: 17.0.8
Ruby:
version: 3.3.5
path: C:\tools\ruby33\bin\ruby.EXE
npmPackages:
"@react-native-community/cli":
installed: 15.0.1
wanted: 15.0.1
react:
installed: 18.3.1
wanted: 18.3.1
react-native:
installed: 0.76.5
wanted: 0.76.5
react-native-windows: Not Found
npmGlobalPackages:
"*react-native*": Not Found
Android:
hermesEnabled: true
newArchEnabled: false
iOS:
hermesEnabled: Not found
newArchEnabled: Not found
Stacktrace or Logs
12-30 23:12:50.002 559 602 I ActivityManager: Start proc 24555:com.android.vending/u0a131 for service {com.android.vending/com.google.android.finsky.externalreferrer.GetInstallReferrerService}
12-30 23:16:49.935 25681 25681 I InstallReferrer: Emitted value: false
12-30 23:16:51.084 25681 25782 D InstallReferrerState: OK
12-30 23:16:51.127 25681 25793 I InstallReferrer: Referrer: darius_taylor
12-30 23:16:51.148 25681 25793 I InstallReferrer: Referrer sent to React Native: darius_taylor
I downloaded your repository and tested your code. In debug mode, it didn't work (at least not here).
I believe the issue is that React Native hasn't fully initialized the context yet (i.e., ReactContext hasn't been created), so you won't be able to emit the event to JavaScript. This happens when getReactContext() returns null, which means React Native isn't ready to receive events.
It's not much, but I hope I was able to help in some way.
native log that interests you (in debug and before start react context)
2025-01-04 22:18:20.799 25150-25187 InstallReferrer com.reproducerapp I ReactContext not ready. Queuing referrer.
2025-01-04 22:18:20.799 25150-25187 InstallReferrer com.reproducerapp I ReactContextListener added to handle referrer.
Description
DeviceEventEmitter.addListener is not working in release version, but works completely fine in the debug version of the app.
When added a adblogcat command to observe the event emission from the native code, we can see that data is emitted from the native side of the app, but fails to capture in react side.
Steps to reproduce
Add useEffect in the app.js file to listen for the event.
useEffect(function() {
let deferredLinkSubscription = null
// Adding event listener to handle deferred links
if (Platform.OS === 'android') {
deferredLinkSubscription = DeviceEventEmitter.addListener(
'InstallReferrer',
function(data) {
handleDeferredLinkUrl(data)
}
)
}
return () => {
// Clean up the event listeners on unmount
deferredLinkSubscription?.remove?.()
}
}, [])
React Native Version
0.76.5
Affected Platforms
Runtime - Android
Output of
npx react-native info
Stacktrace or Logs
Reproducer
https://github.com/shriyash-joinroy/referrer-api
Screenshots and Videos
No response
The text was updated successfully, but these errors were encountered: