Home - cleveradssolutions/CAS-Flutter GitHub Wiki


Import CAS.AI Mobile Ads package

Include the CAS.AI for Flutter plugin in your Flutter project.

With Flutter command:

flutter pub add clever_ads_solutions

Note

To receive release updates Subscribe

Now in your Dart code, you can use:

import 'package:clever_ads_solutions/clever_ads_solutions.dart';

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 by using the CAS Gradle plugin for Android and a Ruby CAS script for iOS.

Android CAS Gradle plugin

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.3.0"
}

cas {
  // Plugin configuration
}

Note

Make sure to update the CAS Gradle plugin version whenever you update the CAS Flutter package. The CASGradle plugin version matches the version of the CAS Android SDK. For detailed setup instructions, visit the CAS Android repository.

iOS Ruby CAS Script

The Ruby script performs automatic configuration of your iOS project. To apply it, follow the steps outlined below.

  1. Download the casconfig.rb
  2. Place the script in ios app directory <project>/ios
  3. Open the terminal window and go to ios directory:
cd ios
  1. Run ruby script with your app CAS ID:
ruby casconfig.rb <CAS ID>
What is CAS ID in iOS?

In most cases, a CASID is the same as your app store ID.
You can find an app store ID in the URL of your app’s Apple App Store URL. For example, the URL is apps.apple.com/us/app/id123456789 then app store ID is 123456789.

If you haven't created an CAS account and registered an app yet, now's a great time to do so at https://cas.ai
If you just want to experiment or test the SDK, you can skip the configuration your project.

Note

Repeat the script before every update of the app to make sure you are using up-to-date configurations. For more details about the script and its updates, visit the CAS iOS repository🔗.

iOS Cocoapods

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/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.

Note

Make sure to update the CAS pods version whenever you update the CAS Flutter 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.

Optimal Ads Solution

Recommended for most applications targeting a general or mixed audience. Includes a broad set of stable, high-performance networks.

Android build.gradle:

cas {
    includeOptimalAds = true
}

iOS Podfile:

pod 'CleverAdsSolutions-SDK/Optimal', '4.3.0'

Families Ads Solution

Required for applications directed exclusively at children, in accordance with the Google Play Families Policy and fully compatible with the Children’s Online Privacy Protection Act (COPPA).

Android build.gradle:

cas {
    includeFamiliesAds = true
}

iOS Podfile:

pod 'CleverAdsSolutions-SDK/Families', '4.3.0'

Choice networks

Advanced publishers familiar with ad network integrations can configure their own set of adapters. For detailed instructions on how to integrate specific adapters into your app, refer to the Android wiki page and the iOS wiki page.

Advertising Identifier

CAS Mediation 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.

Android Advertising ID

CAS Mediation allows you to easily enable or disable the use of the Advertising ID, depending on your app’s privacy requirements.

cas {
    useAdvertisingId = true
}

An application must not use an advertising identifier if at least one of the following conditions is true:

  • The app’s target audience includes only children, as defined in the Families Policy.
  • The app is being built for devices that do not use Google Play Services (e.g. Amazon or Huawei devices).

iOS User Tracking usage description

To use the App Tracking Transparency authorization request for accessing the IDFA, update your <project>/ios/Runner/Info.plist to add the NSUserTrackingUsageDescription key (Name in Xcode Property List Editor: Privacy - Tracking Usage Description) with a custom message describing your usage. Below is an example description text:

<key>NSUserTrackingUsageDescription</key>
<string>Your data will remain confidential and will only be used to provide you a better and personalised ad experience</string>

Some examples include:

  • Your data will remain confidential and will only be used to provide you a better and personalised ad experience
  • Your data will be used to provide you a better and personalised ad experience
  • Your data will be used to create a customized experience tailored to your interests
  • Allowing tracking will enable more personalized ads for you
  • We try to show ads for apps and products that will be most interesting to you based on the apps you use
  • This identifier will be used to deliver personalized ads to you
  • This only uses device info for more interesting and relevant ads

(optional) Localizing User Tracking usage description

To optimize performance and to improve the user experience, you can localize the NSUserTrackingUsageDescription string. Please follow the Documentation > Xcode > Localization instructions to learn how to localize your app.
The table below gives you a variety of localizations that you can use at your discretion.

Locale Description
English (en) Your data will remain confidential and will only be used to provide you a better and personalised ad experience
German (de) Ihre Daten bleiben vertraulich und werden nur dazu verwendet, Ihnen ein besseres und personalisiertes Werbeerlebnis zu bieten
French (fr) Vos données resteront confidentielles et seront utilisées uniquement pour vous offrir une expérience publicitaire meilleure et personnalisée
Spanish (es) Sus datos permanecerán confidenciales y solo se utilizarán para brindarle una experiencia publicitaria mejor y personalizada
Ukrainian (uk) Ваші дані залишатимуться конфіденційними та використовуватимуться лише для надання вам кращої та персоналізованої реклами
Russian (ru) Ваши данные останутся конфиденциальными и будут использоваться только для предоставления вам более качественной и персонализированной рекламы
Portuguese (pt) Seus dados permanecerão confidenciais e serão usados apenas para lhe proporcionar uma experiência publicitária melhor e personalizada
Japanese (ja) お客様のデータは機密として保持され、より優れたパーソナライズされた広告エクスペリエンスを提供するためにのみ使用されます

🔗 Next

⚠️ **GitHub.com Fallback** ⚠️