---
page_source: https://juspay.io/sea/docs/express-checkout-sdk-global/capacitor/base-sdk-integration/life-cycle-events
page_title: 7. Life Cycle Events
---


## 7. Life Cycle Events



Express Checkout SDK runs in a fragment. Hence, to handle certain events based upon activity life cycle, client will need to forward those events to Express Checkout SDK.

These events are crucial for seamless functioning of features like OTP reading, App Switches (UPI Intent), Hardware backpress.

Following are the Life cycle events which SDK needs


### Step 7.1. onBackPressed


In order to handle hardware backpress done by user, you have to call `onBackPressed()` on HyperServices Instance in the onBackPressed function of your Checkout Activity.

onBackPressed function returns a boolean. When this return value is true hardware backpressed is consumed by Juspay SDK, if its false you need to handle backpress



#### Code Snippets: -

#### Capacitor Code Snippet:

```capacitor
import { App } from '@capacitor/app';

  .........
  .........

  App.addListener('backButton', async (data) => {
    const { onBackPressed } = await HyperServices.onBackPressed();
    if (!onBackPressed) {
      window.history.back();
    }
  });
```
