Open azrielh opened 2 months ago
That kind of listener will not work on the latest version
Can you try this code
useEffect(() => {
const eventEmitter = new NativeEventEmitter(NativeModules.RnFlybuyCore);
const listener = eventEmitter.addListener(
'orderUpdated',
(event: IOrder) => {
console.log('order updated', event);
},
);
return () => {
listener.remove();
};
}, []);
@azrielh please try the latest version
Sample code
import * as FlyBuyCore from 'react-native-bildit-flybuy-core';
import {
NativeEventEmitter,
NativeModules,
} from 'react-native';
// inside function component
React.useEffect(() => {
FlyBuyCore.startObserver();
return () => {
FlyBuyCore.stopObserver();
};
}, []);
useEffect(() => {
const eventEmitter = new NativeEventEmitter(NativeModules.RnFlybuyCore);
const listener = eventEmitter.addListener(
'orderUpdated',
(event: FlyBuyCore.IOrder) => {
console.log('order updated', event);
},
);
return () => {
listener.remove();
};
}, []);
@azrielh try the latest patch 2.20.9
@addingama, that update cannot happen right now due to https://github.com/BILDIT-Platform/react-native-bildit-flybuy/issues/91
Describe the bug When using the
eventEmitter.addListener
for android builds. We get a system crash when there is anorderUpdated
trigger. with the errorjava.lang.Double cannot be cast to java.lang.String
The eventEmitter works fine on iOS, just an issue with Android.
It could be related to the incoming
event.partnerIdentifier
(and orderId) as it is numeric so in java it may be getting coerced to a Double instead of a string. ie29344426606903296
Example in
useEffect
:Forcing the
event.partnerIdentifier
ororderId
from above to a string does not fix the issue, as it seems to be in the native code.Expected behavior When adding the
eventEmitter.addListener
it should trigger when there is an update to an order to both android and iOS builds.Screenshots
Additional context