Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*.iml
.vscode/
*.code-workspace
.claude/
**/.claude/



Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Complete documentation including installation, usage examples, API reference, an

- **[`cloudx_flutter_sdk/`](cloudx_flutter_sdk/)** - Flutter plugin SDK package
- **[`cloudx_flutter_demo_app/`](cloudx_flutter_demo_app/)** - Demo app with examples
- **[`cloudx-flutter-testing/`](cloudx-flutter-testing/)** - Testing app for wrapper validation

## License

Expand Down
52 changes: 52 additions & 0 deletions cloudx-flutter-testing/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.build/
.buildlog/
.history
.svn/
.swiftpm/
migrate_working_dir/

# Backup files
*.bak
*.backup
*.old
*.orig
*~

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/

# Flutter/Dart/Pub related
**/doc/api/
**/ios/Flutter/.last_build_id
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.pub-cache/
.pub/
/build/

# Symbolication related
app.*.symbols

# Obfuscation related
app.*.map.json

# Android Studio will place build artifacts here
/android/app/debug
/android/app/profile
/android/app/release
30 changes: 30 additions & 0 deletions cloudx-flutter-testing/.metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled and should not be manually edited.

version:
revision: "077b4a4ce10a07b82caa6897f0c626f9c0a3ac90"
channel: "stable"

project_type: app

# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: 077b4a4ce10a07b82caa6897f0c626f9c0a3ac90
base_revision: 077b4a4ce10a07b82caa6897f0c626f9c0a3ac90
- platform: android
create_revision: 077b4a4ce10a07b82caa6897f0c626f9c0a3ac90
base_revision: 077b4a4ce10a07b82caa6897f0c626f9c0a3ac90

# User provided section

# List of Local paths (relative to this file) that should be
# ignored by the migrate tool.
#
# Files that are not part of the templates will be ignored by default.
unmanaged_files:
- 'lib/main.dart'
- 'ios/Runner.xcodeproj/project.pbxproj'
21 changes: 21 additions & 0 deletions cloudx-flutter-testing/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 CloudX

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
178 changes: 178 additions & 0 deletions cloudx-flutter-testing/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
# CloudX Flutter Demo App

A Flutter demo application that demonstrates the integration of the CloudX Flutter SDK with support for banner, MREC, and interstitial ads.

## Features

- **SDK Initialization**: Initialize the CloudX SDK with app key and environment selection
- **Banner Ads**: Create and display banner ads (320x50) with widget-based and programmatic approaches
- **Interstitial Ads**: Create and show full-screen interstitial ads
- **MREC Ads**: Create and display medium rectangle ads (300x250)
- **Tab Navigation**: Easy navigation between different ad types
- **Event Logging**: Comprehensive event logs showing all ad lifecycle callbacks
- **Status Indicators**: Real-time status updates for ad loading and display
- **Error Handling**: Comprehensive error handling and user feedback

## App Structure

The app is organized into the following screens:

1. **Home Screen**: SDK initialization with environment selection (dev/staging/production)
2. **Banner Screen**: Banner ad creation and display with widget and programmatic examples
3. **Interstitial Screen**: Interstitial ad creation and display
4. **MREC Screen**: MREC ad creation and display
5. **Logs Modal**: View all ad lifecycle events with CLXAd metadata

## Architecture

### BaseAdScreen
A base class that provides common functionality for all ad screens:
- Status UI management
- Error handling
- Ad event handling
- Loading state management
- Common UI components

### Individual Ad Screens
Each ad type has its own screen that extends `BaseAdScreen`:
- Implements specific ad creation logic
- Handles ad-specific events
- Provides ad-type-specific UI

## Dependencies

- **cloudx_flutter_sdk**: The Flutter SDK wrapper for CloudX (local path dependency)
- **CloudXCore**: The underlying iOS Objective-C SDK (~> 1.1.40 via CocoaPods)
- **CloudX Android SDK**: The underlying Android SDK (0.5.0 via Maven Central)

## Setup Instructions

### Prerequisites
- Flutter SDK (3.0.0 or later)
- Dart SDK (3.0.0 or later)
- iOS 14.0 or later (for iOS development)
- Xcode 12.0 or later (for iOS development)
- CocoaPods (for iOS development)
- Android API 21+ (for Android development)

### Installation

1. **Clone the repository**:
```bash
git clone https://github.com/cloudx-io/cloudx-flutter.git
cd cloudx-flutter/cloudx_flutter_demo_app
```

2. **Install Flutter dependencies**:
```bash
flutter pub get
```

3. **Install iOS dependencies**:
```bash
cd ios
pod install
cd ..
```

4. **Run the app**:
```bash
# Run on any connected device/simulator
flutter run

# Or specify platform
flutter run -d ios
flutter run -d android
```

## Usage

### 1. Initialize the SDK
- On app launch, select your environment (dev/staging/production)
- The SDK will automatically initialize
- Wait for the success confirmation before testing ads

### 2. Test Different Ad Types
- Navigate to any ad type tab (Banner, Interstitial, MREC)
- **Banner/MREC**: Ads load automatically when you navigate to the tab
- **Interstitial**: Tap "Load Ad" then "Show Ad" when ready
- Monitor the status indicator at the bottom of the screen

### 3. Monitor Ad Events
- Tap the "Logs" button to view all ad lifecycle events
- Each event shows timestamp, event type, and CLXAd metadata (bidder, revenue, etc.)
- Console logs provide additional debugging information
- Status indicators show the current state of each ad

## Configuration

All configuration is centralized in `lib/config/demo_config.dart`:

### Environment Support
- **Development**: For testing with dev servers
- **Staging**: For pre-production testing
- **Production**: For production CloudX servers

### Platform-Specific Configuration
Each environment has separate configurations for iOS and Android:
- **App Keys**: Platform-specific CloudX app keys
- **Placement Names**: Ad unit identifiers (banner, interstitial, MREC)

To modify configurations, edit `lib/config/demo_config.dart`.

## Development

### Adding New Ad Types
1. Create a new screen that extends `BaseAdScreen`
2. Implement the required methods:
- `getAdIdPrefix()`
- `_buildMainContent()`
- `_loadAd()`
- `_showAd()`
3. Add the screen to the main tab navigation

### Customizing UI
- Modify the `_buildMainContent()` method in each screen
- Update the `BaseAdScreen` for common UI changes
- Customize colors, fonts, and layouts in the theme

### Error Handling
- All errors are displayed in alert dialogs
- Network errors are handled gracefully
- Ad loading failures are reported to the user

## Troubleshooting

### Common Issues

1. **SDK not initialized**:
- Make sure to initialize the SDK in the Init tab first
- Check that the app key is correct

2. **Ad loading fails**:
- Verify network connectivity
- Check that the placement IDs are correct
- Ensure the SDK is properly initialized

3. **Build errors**:
- Run `flutter clean` and `flutter pub get`
- Run `cd ios && pod install && cd ..`
- Check that all dependencies are properly installed

### Debug Information

**Verbose Logging**: This demo app has verbose logging enabled by default to help with debugging:
- Calls `CloudX.setLoggingEnabled(true)` before SDK initialization
- All ad lifecycle events are logged to the console
- Use the in-app Logs viewer to see event history with metadata

Additional debugging tips:
- Check the console for detailed error messages
- Use the Logs button to view all ad events in the app
- Monitor the status indicators for real-time feedback
- iOS logs will appear in Xcode console and device logs
- Android logs can be viewed with `adb logcat | grep CX:`

## License

This project is licensed under the same license as the CloudX SDK.
28 changes: 28 additions & 0 deletions cloudx-flutter-testing/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# This file configures the analyzer, which statically analyzes Dart code to
# check for errors, warnings, and lints.
#
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
# invoked from the command line by running `flutter analyze`.

# The following line activates a set of recommended lints for Flutter apps,
# packages, and plugins designed to encourage good coding practices.
include: package:flutter_lints/flutter.yaml

linter:
# The lint rules applied to this project can be customized in the
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
# included above or to enable additional rules. A list of all available lints
# and their documentation is published at https://dart.dev/lints.
#
# Instead of disabling a lint rule for the entire project in the
# section below, it can also be suppressed for a single line of code
# or a specific dart file by using the `// ignore: name_of_lint` and
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
# producing the lint.
rules:
# avoid_print: false # Uncomment to disable the `avoid_print` rule
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule

# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
14 changes: 14 additions & 0 deletions cloudx-flutter-testing/android/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
gradle-wrapper.jar
/.gradle
/captures/
/gradlew
/gradlew.bat
/local.properties
GeneratedPluginRegistrant.java
.cxx/

# Remember to never publicly share your keystore.
# See https://flutter.dev/to/reference-keystore
key.properties
**/*.keystore
**/*.jks
50 changes: 50 additions & 0 deletions cloudx-flutter-testing/android/app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
plugins {
id("com.android.application")
id("kotlin-android")
// The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
id("dev.flutter.flutter-gradle-plugin")
}

android {
namespace = "io.cloudx.demo.demoapp"
compileSdk = 36
ndkVersion = flutter.ndkVersion

compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

kotlinOptions {
jvmTarget = "1.8"
}

defaultConfig {
applicationId = "io.cloudx.demo.demoapp"
// You can update the following values to match your application needs.
// For more information, see: https://flutter.dev/to/review-gradle-config.
minSdk = flutter.minSdkVersion // Required by CloudX Android SDK
targetSdk = 36
versionCode = flutter.versionCode
versionName = flutter.versionName
}

buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig = signingConfigs.getByName("debug")
}
}
}

flutter {
source = "../.."
}

dependencies {
// CloudX SDK from Maven Central
implementation("io.cloudx:sdk:0.6.1")
implementation("io.cloudx:adapter-cloudx:0.6.1")
implementation("io.cloudx:adapter-meta:0.6.1")
}
Loading