> ## Documentation Index
> Fetch the complete documentation index at: https://guide.daro.so/llms.txt
> Use this file to discover all available pages before exploring further.

# Migration Guide

> Migrate from the legacy React Native SDK (before 2.0.0) to the DARO 2.0 SDK.

Review the [DARO 2.0 SDK overview](/en/new-daro-sdk/overview) and [common migration guide](/en/new-daro-sdk/migration-guide), then follow the steps below. See [legacy SDK (before 2.0.0) support](/en/new-daro-sdk/legacy-support) for the scope of support for earlier versions.

<Warning>
  Existing Ad Unit IDs continue to work with the DARO 2.0 SDK and do not need to be reissued or replaced. For new integrations or when copying a value, use the Ad Unit Key from the updated dashboard. Keep existing Ad Unit IDs in app versions that use the legacy SDK (before 2.0.0); newly created Ad Unit keys do not work with that SDK. ID compatibility does not remove the need to review package, initialization, and ad API changes.
</Warning>

Your starting point depends on the package you use today.

| Package in use | How to migrate |
| - | - |
| `react-native-daro-m` | Remove the package and replace it with `react-native-daro`. `react-native-daro-m` had no Expo config plugin, so apply the step 3 and 4 settings from scratch. |
| `react-native-daro` (before 2.0.0) | Update the same package to 2.0.0 or later, and replace the existing key files and Expo config plugin settings following steps 2 and 4. |

## 1. Update the dashboard

* In the DARO dashboard, select the app you are migrating and complete the update.
* Find the **Integration Key** and Ad Unit Keys for the Android app and the iOS app separately.

## 2. Remove legacy key files and settings

* Remove `daro-services.json`, `daro-service.json`, `daro-key.txt`, `android-daro-key.txt`, `ios-daro-key.txt`, and any settings that reference them. Also check file references registered in Xcode and the **Copy Bundle Resources** entries.
* Remove the existing `daroAppKey` setting from `android/gradle.properties` and your build scripts.
* If you used the Expo config plugin, remove `daroAppKey`, `daroKeyFile`, and `admobAppId`.

<Warning>
  - The DARO 2.0 SDK config plugin fails with an error and stops the prebuild if any of these three legacy settings remain.
  - `admobAppId` existed only in the iOS settings, so check it as well.
</Warning>

## 3. Configure DARO integration tools

* If you used `react-native-daro-m`, remove it and install `react-native-daro`.
* If you already use `react-native-daro`, update the same package.

```bash theme={null}
npm uninstall react-native-daro-m
npm i react-native-daro@2.0.0
```

* The two packages pull in different native SDKs, so do not keep both.

* Follow the [Android migration guide](/en/sdk-integration-v2/android/migration-guide) and the [iOS migration guide](/en/sdk-integration-v2/ios_new/migration-guide) to prepare the build tools the new SDK requires.

* Expo projects use the config plugin described in [Get Started](/en/sdk-integration-v2/react-native/get-started).

* React Native CLI projects follow the manual setup in the same document.

* Do not apply the previous plugin alongside the new one.

<Note>
  - `react-native-daro` declares Expo 50 or later as a peer dependency.
  - On an earlier version, upgrade Expo first or use the React Native CLI manual setup.
</Note>

## 4. Configure the Integration Key and app settings

* Get the Integration Key for each platform's app from the dashboard and configure it.
* Use the key that belongs to each app for Android and iOS.
* The Expo config plugin takes a single key per platform.

```json Before app.json theme={null}
{
  "expo": {
    "plugins": [
      [
        "react-native-daro",
        {
          "ios": {
            "daroAppKey": "YOUR_PREVIOUS_IOS_APP_KEY",
            "daroKeyFile": "./ios-daro-key.txt",
            "admobAppId": "ca-app-pub-xxxxxxxx~xxxxxxxx"
          },
          "android": {
            "daroAppKey": "YOUR_PREVIOUS_ANDROID_APP_KEY",
            "daroKeyFile": "./android-daro-key.txt"
          }
        }
      ]
    ]
  }
}
```

```json After app.json theme={null}
{
  "expo": {
    "plugins": [
      [
        "react-native-daro",
        {
          "ios": {
            "daroIntegrationKey": "YOUR_IOS_INTEGRATION_KEY"
          },
          "android": {
            "daroIntegrationKey": "YOUR_ANDROID_INTEGRATION_KEY"
          }
        }
      ]
    ]
  }
}
```

<Warning>
  * Run `npx expo prebuild` only after replacing the package in step 3.
  * The `react-native-daro` plugin in `app.json` is resolved from `node_modules`. Running it while the legacy package is still installed loads the previous plugin, which cannot process the new settings.
</Warning>

* After changing the configuration, run `npx expo prebuild`.
* For manual integration, follow the platform settings in [Get Started](/en/sdk-integration-v2/react-native/get-started), and run `pod install` in the `ios/` directory.

## 5. Update app-ads.txt

* Follow the [app-ads.txt guide](/en/app-ads-txt-settings) and publish the latest content provided by the dashboard.
* Confirm that the file is accessible on the website registered in the dashboard.

## 6. Update SDK dependencies and code

### Update import paths

* Update every import path that came from `react-native-daro-m`.

```javascript theme={null}
// Before
import { AdBannerView, AdFormat, initialize } from "react-native-daro-m";

// After
import { AdBannerView, AdFormat, initialize } from "react-native-daro";
```

### Remove placement

* `placement` has been removed from ad creation arguments and from the banner and native components.

```javascript theme={null}
// Before
<AdBannerView
  style={styles.bannerView}
  adFormat={AdFormat.BANNER}
  adUnitId={BANNER_AD_UNIT_ID}
  placement="main_bottom"
/>

// After
<AdBannerView
  style={styles.bannerView}
  adFormat={AdFormat.BANNER}
  adUnitId={BANNER_AD_UNIT_ID}
/>
```

### Move from the static ad API to the Hook or instance API

* The static APIs for interstitial, rewarded, and light popup ads (`InterstitialAd.loadAd` and so on) still work the same way in the DARO 2.0 SDK, but they are deprecated.
* Your app still builds if you move only some of the formats, so you can migrate one format at a time.

<Warning>
  - Static listeners (`InterstitialAd.addAdLoadedEventListener` and so on) do not receive events from ads loaded through the Hook or instance API.
  - When you move a format's loading to the new API, move that format's event listeners as well.
  - If you move only the loading and leave the listeners in place, the callbacks are never called.
</Warning>

```javascript Before — static API theme={null}
import { InterstitialAd } from "react-native-daro-m";

InterstitialAd.addAdLoadedEventListener(() => {
  InterstitialAd.showAd(INTERSTITIAL_AD_UNIT_ID);
});

InterstitialAd.loadAd(INTERSTITIAL_AD_UNIT_ID);
```

```javascript After — Hook API theme={null}
import { Button } from "react-native";
import { useInterstitialAd } from "react-native-daro";

function InterstitialAdButton() {
  const { isLoaded, load, show } = useInterstitialAd(INTERSTITIAL_AD_UNIT_ID, {
    onLoadFailed: (error) => console.log(error.message),
  });

  return (
    <Button
      title={isLoaded ? "Show Ad" : "Load Ad"}
      onPress={() => (isLoaded ? show() : load())}
    />
  );
}
```

* To manage an ad outside a component, use the instance API.
* Registering a listener returns a function that removes it.

```javascript After — instance API theme={null}
import { AdEventType, InterstitialAd } from "react-native-daro";

const ad = InterstitialAd.createForAdRequest(INTERSTITIAL_AD_UNIT_ID);
const removeLoadedListener = ad.addAdEventListener(AdEventType.LOADED, () => {
  ad.show();
});

ad.load();

// When the ad is no longer needed
removeLoadedListener();
ad.removeAllListeners();
```

### Initialization order

* Load ads and render the banner and native components only after `initialize()` completes.
* If your app sets consent states, call `setGdpr`, `setCcpa`, and `setCoppa` before `initialize()`. For child-directed apps, `setCoppa` must already be in effect for the initialization request itself.

### Check each ad format

| Ad format | What to check |
| - | - |
| [Banner / MREC](/en/sdk-integration-v2/react-native/ad-formats/banner) | Remove `placement` from `AdBannerView` and check `adFormat` and the component size. |
| [Native](/en/sdk-integration-v2/react-native/ad-formats/native) | Remove `placement` from `NativeAdView` and check the component bindings. |
| [Interstitial](/en/sdk-integration-v2/react-native/ad-formats/interstitial) | Move to `useInterstitialAd` or the instance API and check the event callbacks. |
| [Rewarded](/en/sdk-integration-v2/react-native/ad-formats/rewarded) | Move to `useRewardedAd` and check the `onReceivedReward` callback. |
| [Light Popup](/en/sdk-integration-v2/react-native/ad-formats/lightpopup) | Move to `useLightPopupAd` and check that `load({ configuration })` applies your settings. |

## What you gain after migrating

* [Native ads](/en/sdk-integration-v2/react-native/ad-formats/native), which `react-native-daro-m` did not provide, are now available.
* `AdInfo` in the ad callbacks adds `mediationPlatform` and `adNetwork`, so you can see which ad demand source filled the ad. The existing fields are unchanged.
* Native ads accept `adChoicesPosition` to set the preferred position of the AdChoices icon.

## Verify before release

* Rebuild the Android and iOS apps, then verify loading, display, dismissal, and callbacks on a real device for every ad format you use.
* If you use rewarded video ads, verify the reward callback as well.
* Keep the existing Ad Unit IDs in released versions that still use the legacy SDK (before 2.0.0).
