google_applovin_unity_ads 1.1.5 google_applovin_unity_ads: ^1.1.5 copied to clipboard
Ads Implement
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:google_applovin_unity_ads/events/admob_events.dart';
import 'package:google_applovin_unity_ads/google_applovin_unity_ads.dart';
import 'package:google_applovin_unity_ads/interestial/interstitial_ad.dart';
import 'package:google_applovin_unity_ads/native/controller.dart';
import 'package:google_applovin_unity_ads/open/app_lifecycle_reactor.dart';
import 'package:google_applovin_unity_ads/open/open_ad.dart';
import 'package:google_applovin_unity_ads/reward/reward_ad.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return ScreenUtilInit(
designSize: Size(double.infinity, double.infinity),
minTextAdapt: true,
splitScreenMode: true,
builder: (context, child) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
},
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({Key? key, required this.title}) : super(key: key);
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
String loadAdMob = "";
String showAdMob = "";
InterstitialAd? interestialAd;
RewardAd? rewardAd;
OpenAd? openAd;
AppLifecycleReactor? _appLifecycleReactor;
Widget nativeAd = Container(
height: 0,
);
void afteradsCallback() {
print("Callback completed after ad function");
}
Future<void> _loadAds() async {
interestialAd ??= InterstitialAd(
listener: (AdmobAdEvent event, Map<String, dynamic>? args) {
GoogleApplovinUnityAds.handleEvent(event, callback: afteradsCallback);
});
interestialAd?.load();
}
Future<void> _loadRewardAds() async {
rewardAd ??= RewardAd(
listener: (AdmobAdEvent event, Map<String, dynamic>? args) {
GoogleApplovinUnityAds.handleEvent(event, callback: afteradsCallback);
});
rewardAd?.load();
// GoogleApplovinUnityAds.showIntraAds(callback: afteradsCallback);
/* setState(() {
nativeAd = GoogleApplovinUnityAds.nativeAds(
NativeSize(Size(double.infinity, 500)), "F");
}); */
}
Future<void> _loadOpenAds() async {
openAd ??= OpenAd(
listener: (AdmobAdEvent event, Map<String, dynamic>? args) {
GoogleApplovinUnityAds.handleEvent(event, callback: afteradsCallback);
});
if(openAd != null) {
openAd!.load();
_appLifecycleReactor =
AppLifecycleReactor(appOpenAdManager: openAd!);
_appLifecycleReactor?.listenToAppStateChanges();
}
// GoogleApplovinUnityAds.showIntraAds(callback: afteradsCallback);
/* setState(() {
nativeAd = GoogleApplovinUnityAds.nativeAds(
NativeSize(Size(double.infinity, 500)), "F");
}); */
}
@override
void initState() {
super.initState();
GoogleApplovinUnityAds.initialize("""
{
"app_logo":"https://play-lh.googleusercontent.com/33_mPNzvE6WRV6czGRm8EhSrSh0G9wnRQRfMXfcqQLU8j3z4UYu7nrgw5SmaP9UFf0U=s180-rw",
"app_title":"YOYO: Live Random Video Chat",
"ads_sequence": [
"google_ads"
],
"more_app_url": "https://play.google.com/store/apps/developer?id=Minichat+inc",
"extra_url": "https://raw.githubusercontent.com/pkbitcoding/booya/main/App_Setting.json",
"ad_setting": {
"app_version_code": 5,
"is_full_ads": false,
"onesignal_id": "ae6e77d4-07e5-42ba-a8ef-6b396d1bfe11",
"ads_loading_text": "Ads will loading...",
"seconds_require_triger_reward": 25,
"global_intra_interval_click": 1,
"interstitial_ad_time_interval": 30
},
"app_update": {
"is_popup_dialog": true,
"is_update_require": false,
"package_id": "com.adult.iptv.hot.playlist",
"website_url": "https://play.google.com/store/apps/details?id=com.adult.iptv.hot.playlist",
"app_icon": "https://play-lh.googleusercontent.com/puoKL06VOKbYoXPB-O2JfueIgMDuy2vGWdSZ7f7XsGG9idZQ7Sr42E54Uv-M5a5fqXo=w240-h480-rw",
"updated_version_code": 50,
"title": "Enjoy Free Live Channels",
"default_message": "Don't feel Alone."
},
"reward_dialog": {
"is_reward_require": true,
"reward_message": "Watch Reward ads for More Random Video call"
},
"exit_dialog": {
"is_exit_require": true,
"exit_title": "Exit",
"exit_message": "Do you want to exit from App?"
},
"About_App": {
"is_override": false,
"is_about_app": true,
"about_title": "Bonita bate-papo por vídeo ao vivo",
"about_message": "Random Video calling app",
"registration_detail": "Bonita bate-papo por vídeo ao vivo",
"version_detail": "version : 1.0.0"
},
"rate_app": {
"is_rate_app": true,
"package_id": "com.minichat.bonita.aovivo",
"rate_app_url": "https://play.google.com/store/apps/details?id=com.minichat.bonita.aovivo",
"rate_message": "Please Rate us and promote us."
},
"share_app": {
"is_share_app": true,
"share_title": "Share link url :https://play.google.com/store/apps/details?id=com.minichat.bonita.aovivo",
"share_message": "Now anyone can getBonita bate-papo por vídeo ao vivo app : https://play.google.com/store/apps/details?id=com.minichat.bonita.aovivo"
},
"privacy_policy": {
"is_privacy_policy": true,
"is_system_browser": true,
"privacy_policy": "https://pages.flycricket.io/bonita-bate-papo-por/privacy.html"
},
"terms_of_use": {
"is_terms_of_use": true,
"is_system_browser": true,
"terms_of_use": "https://pages.flycricket.io/bonita-bate-papo-por/privacy.html"
},
"error_report": {
"is_error_report_support": true,
"email_id": "mailto:minichat.inc@gmail.com"
},
"feedback_support": {
"is_feedback_support": true,
"email_id":"mailto:minichat.inc@gmail.com",
"feedback_title": "Feedback on Bonita bate-papo por vídeo ao vivo",
"feedback_message": "Hi,\n\n\nYour Feedback Bonita bate-papo por vídeo ao vivo! I would like to give you some feedback:",
"email_subject": "Feedback on Bonita bate-papo por vídeo ao vivo",
"email_message": "Hi,\n\n\nYour Feedback Bonita bate-papo por vídeo ao vivo! I would like to give you some feedback:"
},
"google_ads": {
"banner_ad_unit_id_android": "/6499/example/banner",
"interstitial_ad_unit_id_android": "/6499/example/interstitial",
"app_open_ad_unit_id_android": "/6499/example/app-open",
"native_ads_unit_id_android": "/6499/example/native",
"rewared_ads_unit_id": "/21775744923/example/rewarded_interstitial",
"native_video_ads_unit_id_android": "/6499/example/native-video",
"is_banner_ads": true,
"is_open_ads": true,
"is_interstitial_ads": true,
"is_rewared_ads": true,
"is_native_ads": true,
"no_of_click_interstitial": 3
},
"facebook_ads": {
"banner_ad_unit_id_android": "IMG_16_9_APP_INSTALL#2312433698835503_2964944860251047",
"interstitial_ad_unit_id_android": "IMG_16_9_APP_INSTALL#2312433698835503_2650502525028617",
"rewared_ads_unit_id": "618306899712519_645292513680624",
"native_ads_unit_id_android": "IMG_16_9_APP_INSTALL#2312433698835503_2964952163583650",
"is_banner_ads": true,
"is_interstitial_ads": true,
"is_rewared_ads": true,
"is_native_ads": true
},
"custom_ads": {
"qureka_link": "https://294.set.predchamp.com/",
"is_quraka_banner": true,
"is_quraka_intera": true,
"is_quraka_native": true,
"is_quraka_open_ad": true,
"close_button_to_direct_web": true,
"quraka_intra_image": [
"https://github.com/pragneshpalsanabitcoding/image_quraka/blob/main/360X640_1.png?raw=true",
"https://github.com/pragneshpalsanabitcoding/image_quraka/blob/main/360X640_2.png?raw=true",
"https://github.com/pragneshpalsanabitcoding/image_quraka/blob/main/360X640_3.png?raw=true",
"https://github.com/pragneshpalsanabitcoding/image_quraka/blob/main/360X640_4.png?raw=true",
"https://github.com/pragneshpalsanabitcoding/image_quraka/blob/main/360X640_5.png?raw=true",
"https://github.com/pragneshpalsanabitcoding/image_quraka/blob/main/360X640_6.png?raw=true"
],
"quraka_native_image": [
"https://github.com/pragneshpalsanabitcoding/image_quraka/blob/main/2.jpg?raw=true",
"https://github.com/pragneshpalsanabitcoding/image_quraka/blob/main/3.jpg?raw=true",
"https://github.com/pragneshpalsanabitcoding/image_quraka/blob/main/320x50.jpg?raw=true",
"https://github.com/pragneshpalsanabitcoding/image_quraka/blob/main/4.jpg?raw=true",
"https://github.com/pragneshpalsanabitcoding/image_quraka/blob/main/5.jpg?raw=true",
"https://github.com/pragneshpalsanabitcoding/image_quraka/blob/main/6.jpg?raw=true"
],
"quraka_banner_image": [
"https://github.com/pragneshpalsanabitcoding/image_quraka/blob/main/2.jpg?raw=true",
"https://github.com/pragneshpalsanabitcoding/image_quraka/blob/main/3.jpg?raw=true",
"https://github.com/pragneshpalsanabitcoding/image_quraka/blob/main/320x50.jpg?raw=true",
"https://github.com/pragneshpalsanabitcoding/image_quraka/blob/main/4.jpg?raw=true",
"https://github.com/pragneshpalsanabitcoding/image_quraka/blob/main/5.jpg?raw=true",
"https://github.com/pragneshpalsanabitcoding/image_quraka/blob/main/6.jpg?raw=true"
],
"quraka_open_ad_image": {
"live_apps_json_url": [
{
"fields": {
"Links": "https://play.google.com/store/apps/details?id=com.yoyolive.llc",
"image": "https://play-lh.googleusercontent.com/33_mPNzvE6WRV6czGRm8EhSrSh0G9wnRQRfMXfcqQLU8j3z4UYu7nrgw5SmaP9UFf0U=s180-rw",
"title": "YOYO: Live Random Video Chat"
}
},
{
"fields": {
"Links": "https://play.google.com/store/apps/details?id=com.money_count_save",
"image": "https://play-lh.googleusercontent.com/kB7MXSAbO8vKrfbnM8QrzIcNbNm2tWH8rImp5xsIZY1lwKqK3FkNkEFRQpyskJliEbQ=s180-rw",
"title": "Cash Counter : Cash Calculator"
}
}
],
"is_live_apps": true,
"open_ad_timer": 8,
"is_live_apps_randomly": false,
"quraka_image": [
"https://github.com/pragneshpalsanabitcoding/image_quraka/blob/main/2.jpg?raw=true",
"https://github.com/pragneshpalsanabitcoding/image_quraka/blob/main/3.jpg?raw=true",
"https://github.com/pragneshpalsanabitcoding/image_quraka/blob/main/320x50.jpg?raw=true",
"https://github.com/pragneshpalsanabitcoding/image_quraka/blob/main/4.jpg?raw=true",
"https://github.com/pragneshpalsanabitcoding/image_quraka/blob/main/5.jpg?raw=true",
"https://github.com/pragneshpalsanabitcoding/image_quraka/blob/main/6.jpg?raw=true"
]
}
},
"app_lovin": {
"is_unlimited_ads": true,
"id_unit_banner": "56a2a4469137334d",
"id_unit_intra": "3a64cf25f817c857",
"id_unit_native": "",
"id_unit_native_multiple":
{
"small":"",
"medium":"",
"manual":"5e7d28c22a6f6d79"
},
"rewared_ads_unit_id": "a9f4669e2348538e",
"is_banner_ads": true,
"is_interstitial_ads": true,
"is_native_ads": true,
"is_rewared_ads": true
},
"unity_ads": {
"game_id": "4737797",
"is_intra_ads": true,
"is_banner_ads": true,
"is_rewared_ads": true
}
}
""", callback: () => {_loadOpenAds()});
}
openAdCallback() {
print("CHECK openAdCallback -------------------------- ");
}
@override
Widget build(BuildContext context) {
ScreenUtil.init(context);
return SafeArea(
child: Column(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Container(
margin: EdgeInsets.all(8.0),
width: double.infinity,
height: 60,
child: Material(
color: Colors.transparent,
child: InkWell(
borderRadius: BorderRadius.all(Radius.circular(10)),
onTap: () => _loadAds(),
child: Ink(
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(10)),
color: Colors.black,
),
alignment: Alignment.center,
child: Padding(
padding: EdgeInsets.symmetric(vertical: 16.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text("Show Native Ads",
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
color: Colors.white)),
],
),
),
),
),
),
)),
SizedBox(height: 50.h,),
Container(
margin: EdgeInsets.all(8.0),
width: double.infinity,
height: 60,
child: Material(
color: Colors.transparent,
child: InkWell(
borderRadius: BorderRadius.all(Radius.circular(10)),
onTap: () => _loadRewardAds(),
child: Ink(
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(10)),
color: Colors.black,
),
alignment: Alignment.center,
child: Padding(
padding: EdgeInsets.symmetric(vertical: 16.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text("Show Reward Ads",
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
color: Colors.white)),
],
),
),
),
),
),
)),
nativeAd
],
));
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
// Center is a layout widget. It takes a single child and positions it
// in the middle of the parent.
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Container(
margin: EdgeInsets.all(8.0),
width: double.infinity,
height: 60,
child: Material(
color: Colors.transparent,
child: InkWell(
borderRadius: BorderRadius.all(Radius.circular(10)),
onTap: () => _loadAds(),
child: Ink(
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(10)),
color: Colors.black,
),
alignment: Alignment.center,
child: Padding(
padding: EdgeInsets.symmetric(vertical: 16.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text("Show Intrestial Ads",
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
color: Colors.white)),
],
),
),
),
),
),
)),
SizedBox(height: 24.h),
/*Container(
margin: EdgeInsets.all(8.0),
width: double.infinity,
height: 60,
child: Material(
color: Colors.transparent,
child: InkWell(
borderRadius: BorderRadius.all(Radius.circular(10)),
onTap: () => _loadRewardAds(),
child: Ink(
child: Container(
decoration: BoxDecoration(
borderRadius:
BorderRadius.all(Radius.circular(10)),
color: Colors.black,
),
alignment: Alignment.center,
child: Padding(
padding: EdgeInsets.symmetric(vertical: 16.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text("Show Reward Ads",
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
color: Colors.white)),
],
),
),
),
),
),
)),
SizedBox(height: 16.h),*/
/*GoogleApplovinUnityAds.nativeAds(NativeSize.SMALL_NATIVE, Colors.transparent),
SizedBox(height: 16.h),*/
Container(height: 100, child: Container()),
],
),
) // This trailing comma makes auto-formatting nicer for build methods.
);
}
}