# React Native listeners

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

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

<div class="tab-panel" data-tab-id="tabgrp-689-0" data-tab-group="tabgrp-689" 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-690">
<div class="tab-buttons"><button class="tab-button" data-tab-id="tabgrp-690-0" data-tab-group="tabgrp-690" data-tab-active="true">JavaScript</button></div>

<div class="tab-panel" data-tab-id="tabgrp-690-0" data-tab-group="tabgrp-690" 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-691">
<div class="tab-buttons"><button class="tab-button" data-tab-id="tabgrp-691-0" data-tab-group="tabgrp-691" data-tab-active="true">JavaScript</button></div>

<div class="tab-panel" data-tab-id="tabgrp-691-0" data-tab-group="tabgrp-691" 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-692">
<div class="tab-buttons"><button class="tab-button" data-tab-id="tabgrp-692-0" data-tab-group="tabgrp-692" data-tab-active="true">JavaScript</button></div>

<div class="tab-panel" data-tab-id="tabgrp-692-0" data-tab-group="tabgrp-692" 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-693">
<div class="tab-buttons"><button class="tab-button" data-tab-id="tabgrp-693-0" data-tab-group="tabgrp-693" data-tab-active="true">JavaScript</button></div>

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

```JavaScript
Synerise.Injector.setInAppMessageListener({
  shouldPresent: function(data) {
    return true;
  },
  // 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 a individual context for an in-app message is needed
  contextIsNeeded: function(data) {
    return {}
  },
  // 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>


---
---

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