Geniee SDK Flutter Plugin
The geniee_sdk_flutter plugin brings the power of the Geniee SDK to your Flutter applications, enabling seamless integration of advertising and mediation solutions across both Android and iOS platforms. With support for multiple ad networks through mediation adapters, this plugin helps developers maximize monetization opportunities.
Features
- Ad Integration: Display ads effortlessly using the Geniee SDK.
- Mediation Support: Compatible with leading ad networks via mediation adapters: Pangle, AppLovin, Google Ad Manager, Vungle, Unity Ads, Maio.
- Cross-Platform: Fully functional on both Android and iOS.
Getting Started
This plugin is a Flutter plug-in package, providing platform-specific implementations for Android and iOS.
Prerequisites
- Flutter SDK (see Flutter installation guide).
- Android: Android Studio with SDK 21 or later.
- iOS: Xcode 15.0 or later.
- Minimum deployment targets: Android API 21 (5.0 Lollipop), iOS 12.0.
Installation
-
Add the dependency
Add this to yourpubspec.yaml:dependencies: geniee_sdk_flutter: ^0.0.2Then run:
flutter pub get. -
Android Setup
Inandroid/app/build.gradle, ensureminSdkVersionis 21 or higher:
android {
defaultConfig {
minSdkVersion 21
}
}
Dependencies are managed via Gradle.
-
iOS Setup
Openios/Runner.xcworkspacein Xcode, set deployment target to iOS 12.0+. Then, inios/, run:pod install. -
Configure Permissions (if required)
- Android: Add to
android/app/src/main/AndroidManifest.xml:
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="YOUR_GOOGLE_AD_MANAGER_APP_ID"/>
- iOS: Add to
ios/Runner/Info.plist(e.g., for Google Ad Manager):
<key>GADApplicationIdentifier</key>
<string>YOUR_GOOGLE_AD_MANAGER_APP_ID</string> <key>NSUserTrackingUsageDescription</key>
<string>This identifier will be used to deliver personalized ads to you.</string>
Check each ad network’s docs for specifics.
Usage Here’s a basic example of initializing the Geniee SDK:
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:geniee_sdk_flutter/geniee_sdk_flutter.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
String _interstitialAdStatus = 'Not Loaded';
String _rewardedVideoAdStatus = 'Not Loaded';
String bannerZoneId =
defaultTargetPlatform == TargetPlatform.android
? "<BANNER_ANDROID_ZONE_ID>"
: "<BANNER_IOS_ZONE_ID>";
String interstitialZoneId =
defaultTargetPlatform == TargetPlatform.android
? "<INTERSTITIAL_ANDROID_ZONE_ID>"
: "<INTERSTITIAL_IOS_ZONE_ID>";
String rewardZoneId =
defaultTargetPlatform == TargetPlatform.android
? "<REWARD_ANDROID_ZONE_ID>"
: "<REWARD_IOS_ZONE_ID>";
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: Scaffold(
resizeToAvoidBottomInset: false,
appBar: AppBar(
title: const Text(
'Geniee SDK Flutter Demo',
style: const TextStyle(fontSize: 28, fontWeight: FontWeight.bold),
),
centerTitle: true,
),
body: Padding(
padding: const EdgeInsets.only(left: 16.0, right: 16.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Card(
elevation: 4,
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
children: [
Text(
'Banner Ad',
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 16, width: double.infinity),
Container(
width: 320.0,
height: 50.0,
decoration: BoxDecoration(
border: Border.all(color: Colors.black, width: 1.0),
),
child: GenieeBannerAd(
appId: bannerZoneId,
width: 320.0,
height: 50.0,
onAdReceived: () => print("Banner Ad: onAdReceived"),
onAdFailed:
(error) =>
print('Banner Ad: onAdFailed - $error'),
onAdHidden: () => print('Banner Ad: onAdHidden'),
onStartExternalBrowser:
() => print('Banner Ad: onStartExternalBrowser'),
),
),
],
),
),
),
const SizedBox(height: 8),
Card(
elevation: 4,
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
children: [
Text(
'Interstitial Ad Status: $_interstitialAdStatus',
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 16, width: double.infinity),
SizedBox(
width: double.infinity,
child: ElevatedButton(
onPressed: () async {
setState(() {
_interstitialAdStatus = 'Loading...';
});
GenieeInterstitialAd.loadAd(
zoneId: interstitialZoneId,
onAdReceived: () {
print('Interstitial ad loaded successfully');
setState(() {
_interstitialAdStatus = 'Ad loaded';
});
},
onAdFailed: (error) {
print('Failed to load interstitial ad: $error');
setState(() {
_interstitialAdStatus = 'Ad failed: $error';
});
},
onAdShown: () {
print('Interstitial ad shown');
setState(() {
_interstitialAdStatus = 'Ad shown';
});
},
onAdClicked: () {
print('Interstitial ad clicked');
setState(() {
_interstitialAdStatus = 'Ad clicked';
});
},
onAdClosed: () {
print('Interstitial ad dismissed');
setState(() {
_interstitialAdStatus = 'Ad closed';
});
},
);
},
child: const Text(
'Load Interstitial',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w500,
),
),
),
),
SizedBox(
width: double.infinity,
child: ElevatedButton(
onPressed: () async {
if (await GenieeInterstitialAd.canShowAd()) {
await GenieeInterstitialAd.showAd();
} else {
print('Interstitial Ad Not Ready');
}
},
child: const Text(
'Show Interstitial',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w500,
),
),
),
),
],
),
),
),
const SizedBox(height: 8),
Card(
elevation: 4,
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
children: [
Text(
'Rewarded Video Status: $_rewardedVideoAdStatus',
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 16, width: double.infinity),
SizedBox(
width: double.infinity,
child: ElevatedButton(
onPressed: () async {
setState(() {
_rewardedVideoAdStatus = 'Loading...';
});
GenieeRewardedVideoAd.loadAd(
zoneId: rewardZoneId,
useRTB: false,
onAdLoaded: () {
setState(() {
_rewardedVideoAdStatus = 'Ad loaded';
});
},
onAdFailedToLoad: (error) {
setState(() {
_rewardedVideoAdStatus = 'Ad failed: $error}';
});
},
onAdDismissed: () {
setState(() {
_rewardedVideoAdStatus = 'Ad closed';
});
},
onAdStarted: () {
setState(() {
_rewardedVideoAdStatus = 'Ad started';
});
},
onAdRewarded: (rewardItem) {
setState(() {
_rewardedVideoAdStatus =
'Ad rewarded: ${rewardItem.type} - ${rewardItem.amount}';
});
},
);
},
child: const Text(
'Load Rewarded Video',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w500,
),
),
),
),
SizedBox(
width: double.infinity,
child: ElevatedButton(
onPressed: () async {
if (await GenieeRewardedVideoAd.canShowAd()) {
await GenieeRewardedVideoAd.showAd();
print('Rewarded Video Ad Shown');
} else {
print('Rewarded Video Ad Not Ready');
}
},
child: const Text(
'Show Rewarded Video',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w500,
),
),
),
),
],
),
),
),
],
),
),
),
);
}
}
Example Project
Run the example in example/:
cd example
flutter pub get
flutter run