CAS.AI plugin for ReactNative
Integrating CAS SDK into an app is the first step toward displaying ads and earning revenue. Once you've integrated and initialized the SDK, you can choose an ad format and follow the steps to implement it.
Prerequisites
Make sure that your app's build file uses the following values:
- For Android:
- Minimum API level
23or higher
- Minimum API level
- For iOS:
- Use Xcode
26.0or higher - Minimum Target iOS version
13.0or higher
- Use Xcode
Import CAS.AI Mobile Ads package
Include the CAS.AI plugin for ReactNative in your ReactNative project.
npm install react-native-cas
Subscribe
Subscribe to receive notifications about CAS updates.
Now in your code, you can use:
import * as CASModule from 'react-native-cas';
Platform specific setup
To monetize your app using CAS.AI mediation, in addition to importing the package, you need to configure your Android and iOS projects.
Android setup
The CAS Android SDK provide a Gradle Plugin to simplify and automate certain integration steps.
Our plugin will automatically add mediated network dependencies to your project, which you configure in an cas { } block.
In your Android app Gradle file (usually <project>/android/app/build.gradle), add the com.cleveradssolutions.gradle-plugin inside the plugins block.
plugins {
id("com.android.application") // before CAS plugin
id("com.cleveradssolutions.gradle-plugin") version "4.6.3"
}
cas {
// Plugin configuration
}
Make sure to update the CAS Gradle plugin version whenever you update the CAS ReactNative package. The CASGradle plugin version matches the version of the CAS Android SDK. For detailed setup instructions, visit the CAS Android repository.
Some advertising SDKs are published in their own Maven repositories. To allow Gradle to download the required artifacts, you need to add the advertising Maven repositories to your Gradle file.
iOS setup
React Native automatically adds an Xcode Build Phase to run the Ruby script for CAS project configuration.
To complete the setup, you need to add the <key>CASAIAppIdentifier</key> property with the <string>CASID</string> value to the <project>/ios/Runner/Info.plist.
| Key | Type | Value |
|---|---|---|
| Information Property List | Dictionary | |
| ▼ CASAIAppIdentifier | String | CASID |
The <project>/ios/Podfile is a specification that describes the dependencies of your iOS project.
All CAS frameworks are hosted and distributed through their own source repository. Please add CAS source repository url to the beginning of the Podfile:
source 'https://github.com/CocoaPods/Specs.git'
source 'https://github.com/cleveradssolutions/CAS-Specs.git'
Mediation dependencies should be added to the target block, before the end line.
target 'Runner' do
pod ...
...
end
Run pod update terminal command inside the ios directory after modifying the Podfile.
Make sure to update the CAS pods version whenever you update the CAS ReactNative package. The Ads Solution pods version matches the version of the CAS iOS SDK.
Mediated Networks
CAS.AI SDK offers three integration paths. Choose one based on your app’s target audience. If you're unsure which solution best fits your application, please contact your account manager.
Check the details of the ad network adapters supported by CAS.AI Mediation in the Android repository and iOS repository tables.
Advertising Identifier
CAS.AI Plugin uses the Google Advertising ID and Apple Identifier for Advertisers (IDFA) to deliver personalized and more relevant ads to each user.
To enable the use of the Advertising ID in your app, you need to complete the following setup steps.