registerJourneyStateHandler
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.
NamiCustomerManager.registerJourneyStateHandler { journeyState in
print("customer journey state")
print("former subscriber: \(journeyState.formerSubscriber)")
print("in grace period: \(journeyState.inGracePeriod)")
print("in trial period: \(journeyState.inTrialPeriod)")
print("in intro offer period: \(journeyState.inIntroOfferPeriod)")
print("has cancelled subscription: \(journeyState.isCancelled)")
print("in account hold: \(journeyState.inAccountHold)")
print("in pause (Google Play): \(journeyState.inPause)")
}
NamiCustomerManager.registerJourneyStateHandler { journeyState ->
Log.d(LOG_TAG, "Customer journey state:")
Log.d(LOG_TAG, "formerSubscriber ==> ${journeyState.formerSubscriber}")
Log.d(LOG_TAG, "inGracePeriod ==> ${journeyState.inGracePeriod}")
Log.d(LOG_TAG, "inIntroOfferPeriod ==> ${journeyState.inIntroOfferPeriod}")
Log.d(LOG_TAG, "inTrialPeriod ==> ${journeyState.inTrialPeriod}")
Log.d(LOG_TAG, "isCancelled ==> ${journeyState.isCancelled}")
Log.d(LOG_TAG, "inPause ==> ${journeyState.inPause}")
Log.d(LOG_TAG, "inAccountHold ==> ${journeyState.inAccountHold}")
}
NamiCustomerManager.registerJourneyStateHandler().listen((journeyState) {
print("Customer Journey State);
print("formerSubscriber ==> ${journeyState.formerSubscriber}");
print("inGracePeriod ==> ${journeyState.inGracePeriod}");
print("inIntroOfferPeriod ==> ${journeyState.inIntroOfferPeriod}");
print("inTrialPeriod ==> ${journeyState.inTrialPeriod}");
print("isCancelled ==> ${journeyState.isCancelled}");
print("inPause ==> ${journeyState.inPause}");
print("inAccountHold ==> ${journeyState.inAccountHold}");
});
import {NamiCustomerManager, CustomerJourneyState} from 'react-native-nami-sdk';
const getJourneyState = useCallback(async () => {
const myJourneyState = await NamiCustomerManager.journeyState();
console.log('myJourneyState', myJourneyState);
setJourneyState(myJourneyState);
}, []);
useEffect(() => {
getJourneyState();
const subscriptionJourneyStateRemover =
NamiCustomerManager.registerJourneyStateHandler((newJourneyState) => {
console.log('newJourneyState', newJourneyState);
setJourneyState(newJourneyState);
});
return () => {
subscriptionJourneyStateRemover();
};
}, [getJourneyState]);
NamiCustomerManager.RegisterJourneyStateHandler(journeyStateCallback);
Last updated