# Interstitial, Open and Rewarded

## loadAd(adId, callbackEvent)

Load PubStar ads by `Advertisement Id` to application.

### Event

ShowListener

| Callback      | Function                                                 |
| ------------- | -------------------------------------------------------- |
| `onLoadError` | call when load ad failed. return object type `ErrorCode` |
| `onLoaded`    | call when ad loaded                                      |

### Example

```js
Pubstar.loadAd(adId, {
    onLoadError: errorCode => {
        // callback when ad load error
    },
    onLoaded: () => {
        // callback when ad loaded
    },
})
```

## showAd(adId, callbackEvent)

Show ad had loaded before.

### Event

ShowListener

| Callback      | Function                                                                  |
| ------------- | ------------------------------------------------------------------------- |
| `onAdHide`    | call when ad hidden by press close button. return object type `ErrorCode` |
| `onAdShowed`  | call when ad showed                                                       |
| `onShowError` | call when show ad failed. return object type `ErrorCode`                  |

### Example

```js
Pubstar.showAd(adId, {
    onAdHide: reward => {
        // callback when ad hide with reward option
    },
    onAdShowed: () => {
        // callback when ad showed
    },
    onShowError: errorCode => {
        // callback when error
    },
});

```

## loadAndShow(adId, callbackEvent)

Load and immediately show an ad by ID.

### Event

LoadAndShowListener

| Callback      | Function                                                                    |
| ------------- | --------------------------------------------------------------------------- |
| `onLoadError` | call when load ad failed. return object type `ErrorCode`                    |
| `onLoaded`    | call when ad loaded                                                         |
| `onAdHide`    | call when ad hidden by press close button. return object type `RewardModel` |
| `onAdShowed`  | call when ad showed                                                         |
| `onShowError` | call when show ad failed. return object type `ErrorCode`                    |

### Example

```js
Pubstar.loadAndShowAd(
    adId, {
        onLoadError: errorCode => {
            // callback when ad load error
        },
        onLoaded: () => {
            // callback when ad loaded
        },
        onAdHide: reward => {
            // callback when ad hide with reward option
        },
        onAdShowed: () => {
            // callback when ad showed
        },
        onShowError: errorCode => {
            // callback when show error
        },
    }
);

```


---

# Agent Instructions: 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:

```
GET https://pub-star.gitbook.io/docs/react-native-sdk/ads-with-no-view.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
