## Related terms

- mobile\-sdk
- campaign
- event

See the [glossary](/glossary.md) for definitions.

---

# React Native listeners

### Initialization {id=initialization}
A listener to handle the SDK lifecycle events.

<div class="content-tabs code-tabs" data-tab-group="tabgrp-751">
<div class="tab-buttons"><button class="tab-button" data-tab-id="tabgrp-751-0" data-tab-group="tabgrp-751" data-tab-active="true">JavaScript</button></div>

<div class="tab-panel" data-tab-id="tabgrp-751-0" data-tab-group="tabgrp-751" data-tab-active="true">

```JavaScript
Synerise.onReady(function() {
  ...
});

Synerise.onError(function(error) {
  ...
})
```

</div>
</div>


---
---

### NotificationsListener {id=notifications-listener}
A listener to handle actions from the notifications module.


<div class="content-tabs code-tabs" data-tab-group="tabgrp-752">
<div class="tab-buttons"><button class="tab-button" data-tab-id="tabgrp-752-0" data-tab-group="tabgrp-752" data-tab-active="true">JavaScript</button></div>

<div class="tab-panel" data-tab-id="tabgrp-752-0" data-tab-group="tabgrp-752" data-tab-active="true">

```JavaScript
Synerise.Notifications.setListener({
  // The following method is called when Synerise receives a registration token from the native part of application
  // It is optional function
    onRegistrationToken: function(token) {
      ...
  },
  // The following method is called when registration for Push Notifications is needed.
  // It is optional function
  onNotification: function(payload) {
    ...
  },
  // The following method is called when Synerise receives a notification's payload from the native part of application.
  // It is optional function
  onRegistrationRequired: function() {
    ...
  }
});
```

</div>
</div>



<div class="admonition admonition-note"><div class="admonition-icon"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2.5"><path stroke-linecap="round" stroke-linejoin="round" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" /></svg></div><div class="admonition-body"><div class="admonition-content">

After invoking **onRegistrationRequired()** function, you must invoke the [Synerise.Notifications.registerForNotifications(registrationToken, mobileAgreement, onSuccess, onError)](/developers/mobile-sdk/method-reference/react-native/campaigns#register-for-push-notifications) method again.

</div></div></div>


---
---

### ClientStateListener {id=client-state-listener}
A listener to handle customer's sign-in state changes.


<div class="content-tabs code-tabs" data-tab-group="tabgrp-753">
<div class="tab-buttons"><button class="tab-button" data-tab-id="tabgrp-753-0" data-tab-group="tabgrp-753" data-tab-active="true">JavaScript</button></div>

<div class="tab-panel" data-tab-id="tabgrp-753-0" data-tab-group="tabgrp-753" data-tab-active="true">

```JavaScript
Synerise.Client.setClientStateListener({
  // The following method is called when a customer signs in.
  // It is optional function
  onClientSignedIn: function() {
    ...
  },
  // The following method is called when a customer signs out
  // It is optional function
  onClientSignedOut: function(reason) {
    ...
  }
});
```

</div>
</div>


---
---

### InjectorListener {id=injector-listener}
A listener to handle URL and deeplink actions from the injector module.

<div class="content-tabs code-tabs" data-tab-group="tabgrp-754">
<div class="tab-buttons"><button class="tab-button" data-tab-id="tabgrp-754-0" data-tab-group="tabgrp-754" data-tab-active="true">JavaScript</button></div>

<div class="tab-panel" data-tab-id="tabgrp-754-0" data-tab-group="tabgrp-754" data-tab-active="true">

```JavaScript
Synerise.Injector.setListener({
  // The following method is called when Synerise handles URL action from campaign activities
  // It is required function
  onOpenUrl: function(url) {
      ...
  },
  // The following method is called when Synerise handles deep link action from campaign activities
  // It is required function
  onDeepLink: function(deepLink) {
    ...
  }
});
```

</div>
</div>


---
---

### InjectorInAppMessageListener {id=injector-in-app-message-listener}
A listener to handle the states of [in-app messages](/developers/mobile-sdk/campaigns/in-app-message).


<div class="content-tabs code-tabs" data-tab-group="tabgrp-755">
<div class="tab-buttons"><button class="tab-button" data-tab-id="tabgrp-755-0" data-tab-group="tabgrp-755" data-tab-active="true">JavaScript</button></div>

<div class="tab-panel" data-tab-id="tabgrp-755-0" data-tab-group="tabgrp-755" data-tab-active="true">

```JavaScript
Synerise.Injector.setInAppMessageListener({
  // The following method is called after an in-app message appears
  onPresent: function (data) {
    ...
  },
  // The following method is called after an in-app message disappears
  onHide: function(data) {
    ...
  },
  // This method is called when the SRInApp.openUrl(url) method is used in an in-app message.
  onOpenUrl: function (data, url) {
      ...
  },
  // This method is called when the SRInApp.openDeeplink(url) method is used in an in-app message.
  onDeepLink: function (data, deepLink) {
    ...
  },
  // This method is called when the
  // SRInApp.handleCustomAction(name, params) method is used in an in-app message.
  onCustomAction: function(data, name, parameters) {

  }
})
```

</div>
</div>


To provide context for an in-app message, set `Synerise.Injector.inAppContext[InAppContextKey.JinjavaContext]` before the message is rendered. For details, see [In-app context](/developers/mobile-sdk/method-reference/react-native/campaigns#in-app-context).

---
---

### InjectorInlineInAppMessageListener {id=injector-inline-in-app-message-listener}
A listener to handle actions from [inline in-app messages](/developers/mobile-sdk/campaigns/in-app-message/inline-in-app) and to receive components created by the SDK for event-triggered campaigns. In code, the interface is `IInlineInAppMessageListener`


<div class="content-tabs code-tabs" data-tab-group="tabgrp-756">
<div class="tab-buttons"><button class="tab-button" data-tab-id="tabgrp-756-0" data-tab-group="tabgrp-756" data-tab-active="true">JavaScript</button></div>

<div class="tab-panel" data-tab-id="tabgrp-756-0" data-tab-group="tabgrp-756" data-tab-active="true">

```JavaScript
Synerise.Injector.setInlineInAppMessageListener({
  // This method is called when the SDK creates a ready-to-display component
  // after an event-based trigger for a placement with no mounted component.
  onInlineInAppAvailable: (view, data) => {
    ...
  },
  // This method is called when the SRInApp.openUrl(url) method is used in an inline in-app message.
  onOpenUrl: (data, url) => {
    ...
  },
  // This method is called when the SRInApp.openDeeplink(url) method is used in an inline in-app message.
  onDeepLink: (data, deepLink) => {
    ...
  },
  // This method is called when the
  // SRInApp.handleCustomAction(name, params) method is used in an inline in-app message.
  onCustomAction: (data, name, parameters) => {
    ...
  },
  // This method is called when the SRInApp.customMethod(name, params) method is used in an inline in-app message.
  // Resolve the completion exactly once — with success or failure.
  onCustomMethod: (data, name, parameters, completion) => {
    completion.success({});
  },
});
```

</div>
</div>


---
---

## InjectorWalkthroughListener {id=injector-walkthrough-listener}


<div class="admonition admonition-note"><div class="admonition-icon"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2.5"><path stroke-linecap="round" stroke-linejoin="round" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" /></svg></div><div class="admonition-body"><div class="admonition-content">

**InjectorWalkthroughListener** was removed in SDK version 1.0.0..

</div></div></div>


---
---

## InjectorBannerListener {id=injector-banner-listener}


<div class="admonition admonition-note"><div class="admonition-icon"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2.5"><path stroke-linecap="round" stroke-linejoin="round" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" /></svg></div><div class="admonition-body"><div class="admonition-content">

**InjectorBannerListener** was removed in SDK version 1.0.0..

</div></div></div>
