> For the complete documentation index, see [llms.txt](https://docs.namiml.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.namiml.com/sdk-reference/namicustomermanager/registerjourneystatehandler.md).

# 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
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
