# 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.

{% tabs %}
{% tab title="Swift" %}

```swift
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)")
}
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
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}")
}
```

{% endtab %}

{% tab title="Flutter" %}

```dart
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}");
});
```

{% endtab %}

{% tab title="React Native" %}

```javascript
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]);
```

{% endtab %}

{% tab title="Unity" %}

```c
NamiCustomerManager.RegisterJourneyStateHandler(journeyStateCallback);
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.namiml.com/sdk-reference/namicustomermanager/registerjourneystatehandler.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
