Register a callback that will be made any time there's a change to the Journey State for the user. Note that Nami fetches journey state at the start of each session and this is the most likely time to see a change.
@objc static func registerJourneyStateChangedHandler( _ changeHandler: NamiCustomerJourneyChangeHandler? )
public typealias NamiCustomerJourneyChangeHandler = (_ newCustomerJourneyState: CustomerJourneyState) -> ()
NamiCustomerManager.registerCustomerJourneyChangedListener { journeyState ->
// code to process state change
}
NamiCustomerManager.registerCustomerJourneyChangedListener((journeyState) -> {
// code to process state change
}
const onCustomerJourneyStateChanged = (event) => {
// react to journey state change
}
useEffect(() => {
...
if (
eventEmitter?._subscriber?._subscriptionsForType?.CustomerJourneyStateChanged == null
) {
eventEmitter.addListener('CustomerJourneyStateChanged', onCustomerJourneyStateChanged);
}
}, []);