> For the complete documentation index, see [llms.txt](https://documentation.pushly.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://documentation.pushly.com/integration/implementation-steps/react-native/sdk-react-native/sdk-callbacks.md).

# SDK Callbacks

{% hint style="warning" %}
`PushSDKLifecycleCallbacks`, `PermissionLifecycleCallbacks`, `NotificationLifecycleCallbacks`, and `AppMessageLifecycleCallbacks` are **not exported** from `@pushly/push-sdk-react-native`. There is no `import type { X } from '@pushly/push-sdk-react-native'` available for any of them. Pass a plain object literal matching the shape documented below directly to the matching `register*` method — TypeScript will structurally type-check the literal against the method's parameter type without an explicit import.
{% endhint %}

{% hint style="danger" %}
We recommend registering all SDK callbacks once, near your application's root component (eg. in a `useEffect` alongside `PushSDK.setConfiguration`), to ensure proper handling of all events.
{% endhint %}

## SDK Lifecycle Callbacks

These callbacks can be implemented to observe SDK loading and exiting.

In order to implement these callbacks call the SDK's `registerPushSDKLifecycleCallbacks` method with an object literal implementing the callback(s) you need.

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

```tsx
PushSDK.registerPushSDKLifecycleCallbacks({
  // Add function overrides here
});
```

{% endtab %}
{% endtabs %}

The following SDK Lifecycle callbacks are available:

### Finished Loading

This callback is executed when the SDK finishes its initialization and is ready for interaction.

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

```tsx
onPushSDKDidFinishLoading(configuration, subscriberStatus) {
  // Add code to execute after SDK finishes loading
}
```

{% endtab %}
{% endtabs %}

### Exited With Subscriber Status

This callback is executed when the SDK exits and reports the subscriber's current status.

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

```tsx
onPushSDKDidExitWithSubscriberStatus(status, deleted) {
  // Add code to execute after the SDK exits
}
```

{% endtab %}
{% endtabs %}

## Permission Lifecycle Callbacks

These callbacks can be implemented to observe a user's permission authorization changes.

In order to implement these callbacks call the SDK's `registerPermissionLifecycleCallbacks` method with an object literal implementing the callback(s) you need.

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

```tsx
PushSDK.registerPermissionLifecycleCallbacks({
  // Add function overrides here
});
```

{% endtab %}
{% endtabs %}

The following Permission Lifecycle callbacks are available:

### Permission Status Changed

This callback is executed when a user's permission status/authorization has changed.

The `response` variable represents the user's **new** permission status.

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

```tsx
onPushSDKDidReceivePermissionResponse(response) {
  // Add code to execute after a user's notification permission has changed
}
```

{% endtab %}
{% endtabs %}

### Permission Status Changed With Error

This callback is executed when a user's permission status/authorization changes and the SDK also has an error to report for that change.

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

```tsx
onPushSDKDidReceivePermissionResponseWithError(response, error) {
  // Add code to execute after a user's notification permission has
  // changed alongside an error
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
`error` is typed as `Error`, but the SDK delivers an internal `PushSDKException` instance, which is not exported. You can read `error.message`, but you cannot import the class to check `instanceof`.
{% endhint %}

### Registered For Remote Notifications

This callback is executed when the device successfully registers for remote notifications and receives a device token.

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

```tsx
onPushSDKDidRegisterForRemoteNotificationsWithDeviceToken(token) {
  // Add code to execute after the device registers for remote notifications
}
```

{% endtab %}
{% endtabs %}

### Failed To Register For Remote Notifications

This callback is executed when the device fails to register for remote notifications.

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

```tsx
onPushSDKDidFailToRegisterForRemoteNotificationsWithError(error) {
  // Add code to execute after the device fails to register for remote notifications
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
As with `onPushSDKDidReceivePermissionResponseWithError`, `error` is typed as `Error` but delivered as an internal, non-exported `PushSDKException` instance.
{% endhint %}

## Notification Lifecycle Callbacks

These callbacks can be implemented to observe events like impressions, opens, and other interactions with notifications.

In order to implement these callbacks call the SDK's `registerNotificationLifecycleCallbacks` method with an object literal implementing the callback(s) you need.

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

```tsx
PushSDK.registerNotificationLifecycleCallbacks({
  // Add function overrides here
});
```

{% endtab %}
{% endtabs %}

The following Notification Lifecycle callbacks are available:

### Notification Received

This callback is executed when a user receives a notification.

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

```tsx
onPushSDKDidReceiveRemoteNotification(notification) {
  // Add code to execute after the subscriber's device receives a notification
}
```

{% endtab %}
{% endtabs %}

### Notification Opened With URI/URL Destination

This callback is executed when a notification is opened that has a landing URL attached. The subscriber should be navigated to the view that represents the URL.

This method expects a Boolean response (a `Promise<boolean>` is also supported). If the response is `true` then the SDK will perform no additional actions for this notification open. If the response is `false` then the SDK will attempt to navigate the subscriber to the destination URL.

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

```tsx
onPushSDKDidReceiveNotificationDestination(destination, interaction): boolean {
  // Navigate within your application using the destination (the Landing URL)

  // Return true to inform the SDK that it should not navigate
  return true;
}
```

{% endtab %}
{% endtabs %}

See the [Deep Linking](/integration/implementation-steps/react-native/sdk-react-native/deep-linking.md) documentation for a complete example.

## App Message Lifecycle Callbacks

These callbacks can be implemented to observe events like impressions, opens, and other interactions with app messages.

In order to implement these callbacks call the SDK's `registerAppMessageLifecycleCallbacks` method with an object literal implementing the callback(s) you need.

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

```tsx
PushSDK.registerAppMessageLifecycleCallbacks({
  // Add function overrides here
});
```

{% endtab %}
{% endtabs %}

The following App Message Lifecycle callbacks are available:

### App Message Will Present

This callback is executed when an App Message is presented to a user.

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

```tsx
onPushSDKWillPresentAppMessage(appMessage) {
  // Add code to execute when a user's device presents an app message
}
```

{% endtab %}
{% endtabs %}

### App Message Received User Interaction

This callback is executed when a user interacts with an App Message.

This method expects a Boolean response (a `Promise<boolean>` is also supported). If the response is `true` then the SDK will not handle the interaction or attempt to perform navigation when the interaction is an Open URL action. If the response is `false` then the SDK will process the interaction and, if the interaction is an Open URL action, will attempt to navigate the user to the destination URL.

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

```tsx
onPushSDKDidReceiveAppMessageInteraction(interaction, appMessage): boolean {
  // Add code to execute when a user interacts with an app message

  // Return true to inform the SDK that it should not handle the interaction
  return true;
}
```

{% endtab %}
{% endtabs %}

### Failed To Process Message

This callback is executed when the SDK fails to process an App Message.

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

```tsx
onPushSDKDidFailToProcessMessage(message, appMessage) {
  // Add code to execute when the SDK fails to process an app message
}
```

{% 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://documentation.pushly.com/integration/implementation-steps/react-native/sdk-react-native/sdk-callbacks.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.
