google_applovin_unity_ads 1.1.2 google_applovin_unity_ads: ^1.1.2 copied to clipboard
Ads Implement
Add the dependency in pubspec.yaml
:
PERSONAL PACKAGE #
dependencies:
... google_applovin_unity_ads: ^1.0.7
ADD ANDROID MANIFEST #
//PERMISSION
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.gms.permission.AD_ID"/>
//META DATA
<applicaton
...
android:usesCleartextTraffic="true">
<meta-data
android:name="applovin.sdk.key"
android:value="ENTER APPLOVING SDK KEY" />
<meta-data
android:name="applovin.sdk.verbose_logging"
android:value="true" />
<meta-data
android:name="com.google.android.gms.ads.AD_MANAGER_APP"
android:value="true" />
FOR ANDROID SPLASH SCREEN
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="@drawable/launch_background" />
</application>
BUILD GRADLE #
multiDexEnabled true
targetSdkVersion 33
ADD MAIN.DART #
WidgetsFlutterBinding.ensureInitialized();
await APICALLINGMETHOD();
if ((apiModel?.comIptvM3UPlaylists ?? "").toString().isNotEmpty) {
GoogleApplovinUnityAds.initialize(
jsonEncode(apiModel?.comIptvM3UPlaylists).toString(),
callback: () => {runApp(const IPTV())});
}
ADD VERSION CODE FUNCTION
dependencies:
package_info_plus:
int versionCode = 1;
PackageInfo packageInfo = await PackageInfo.fromPlatform();
setState(() {
versionCode = int.parse(packageInfo.buildNumber);
print("11111111- ${versionCode}");
});
ADS_FILE.DART #
import 'package:flutter/material.dart';
import 'package:google_applovin_unity_ads/google_applovin_unity_ads.dart';
import 'package:google_applovin_unity_ads/native/controller.dart';
import 'package:sizer/sizer.dart';
import '../main.dart';
showIntraAds({Function? callback}) async {
ControllerGetX.to.isAdShow.value=true;
if (modelApi!.comBitlinksEnglishIptvM3ulist!.adSetting!.appVersionCode == ControllerGetX.to.versionCode.value) {
if (callback != null) {
callback();
}
} else {
GoogleApplovinUnityAds.showIntraAds(callback: callback);
}
}
Future<void> showRewardAds({Function? callback}) async {
ControllerGetX.to.isAdShow.value=true;
if (modelApi!.comBitlinksEnglishIptvM3ulist!.adSetting!.appVersionCode == ControllerGetX.to.versionCode.value) {
if (callback != null) {
callback();
}
} else {
GoogleApplovinUnityAds.showRewardAds(callback: callback);
}
}
bannerAds() {
if (modelApi!.comBitlinksEnglishIptvM3ulist!.adSetting!.appVersionCode == ControllerGetX.to.versionCode.value ||
modelApi!.comBitlinksEnglishIptvM3ulist!.adsSequence!.isEmpty) {
return Container(
height: 0,
);
}
return GoogleApplovinUnityAds.bannerAds();
}
fullNativeAds() {
if (modelApi!.comBitlinksEnglishIptvM3ulist!.adSetting!.appVersionCode == ControllerGetX.to.versionCode.value ||
modelApi!.comBitlinksEnglishIptvM3ulist!.adsSequence!.isEmpty ||
(modelApi!.comBitlinksEnglishIptvM3ulist!.adsSequence!.length == 1 &&
modelApi!.comBitlinksEnglishIptvM3ulist!.adsSequence![0] == "custom_ads")) {
return Container(
height: 0,
);
}
return GoogleApplovinUnityAds.nativeAds(
NativeSize(Size(double.infinity, 50.h)), "F",
error: Container(
height: 0,
));
}
mediumNativeAds() {
if (modelApi!.comBitlinksEnglishIptvM3ulist!.adSetting!.appVersionCode == ControllerGetX.to.versionCode.value ||
modelApi!.comBitlinksEnglishIptvM3ulist!.adsSequence!.isEmpty ||
(modelApi!.comBitlinksEnglishIptvM3ulist!.adsSequence!.length == 1 &&
modelApi!.comBitlinksEnglishIptvM3ulist!.adsSequence![0] == "custom_ads")) {
return Container(
height: 0,
);
}
return GoogleApplovinUnityAds.nativeAds(
NativeSize(Size(double.infinity, 150.h)), "M");
}
showOpenAd() {
if (modelApi!.comBitlinksEnglishIptvM3ulist!.adSetting!.appVersionCode == ControllerGetX.to.versionCode.value ||
modelApi!.comBitlinksEnglishIptvM3ulist!.adsSequence!.isEmpty) {
return;
}
GoogleApplovinUnityAds.showOpenAds();
}
smallNativeAds() {
if (modelApi!.comBitlinksEnglishIptvM3ulist!.adSetting!.appVersionCode == ControllerGetX.to.versionCode.value ||
modelApi!.comBitlinksEnglishIptvM3ulist!.adsSequence!.isEmpty ||
(modelApi!.comBitlinksEnglishIptvM3ulist!.adsSequence!.length == 1 &&
modelApi!.comBitlinksEnglishIptvM3ulist!.adsSequence![0] == "custom_ads")) {
return Container(
height: 0,
);
}
return GoogleApplovinUnityAds.nativeAds(
NativeSize(Size(double.infinity, 50.h)), "S");
}
isFullAdss(){
modelApi!.comBitlinksEnglishIptvM3ulist!.adSetting!.isFullAds==true?
showIntraAds():Container();
}
isFullAdssNative(){
return modelApi!.comBitlinksEnglishIptvM3ulist!.adSetting!.isFullAds==true?
mediumNativeAds():Container();
}
OPEN ADS #
// abstract class for Open Ad
// Normal statefullwidget
abstract class OpenAdState<T extends StatefulWidget> extends State<T> with WidgetsBindingObserver {
@override
void initState() {
super.initState();
WidgetsBinding.instance.addObserver(this);
}
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
print('setp 1==================$state');
if (state == AppLifecycleState.resumed) {
print('setp 2==================Resume${ControllerGetX.to.isAdShow.value}');
if(!ControllerGetX.to.isAdShow.value) {
print('setp 3==================');
ControllerGetX.to.isAdShow.value = true;
GoogleApplovinUnityAds.showOpenAds();
}
}
if (state == AppLifecycleState.paused) {
ControllerGetX.to.isAdShow.value = false;
}
}
@override
void dispose() {
super.dispose();
WidgetsBinding.instance.removeObserver(this);
}
}
// When GetX will be used
abstract class OpenAdState<T extends GetxController> extends GetView<T>
with WidgetsBindingObserver {
OpenAdState({Key? key}) : super(key: key) {
WidgetsBinding.instance.addPostFrameCallback((_) => initialization());
}
Future<void> initialization({BuildContext? context}) async {
WidgetsBinding.instance.addObserver(this);
}
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
print("Yes yes Open Adddddddsss $state");
if (state == AppLifecycleState.resumed) {
print("Yes yes Open Adddddddsss $state 121212");
if (!WelcomeController.to.isAdShow.value) {
print("Yes yes Open Adddddddsss $state 2323232323");
WelcomeController.to.isAdShow.value = true;
GoogleApplovinUnityAds.showOpenAds();
}
}
if (state == AppLifecycleState.paused) {
print("Yes yes Open Adddddddsss $state 4545454545454");
WelcomeController.to.isAdShow.value = false;
}
}
@override
void dispose() {
WidgetsBinding.instance.removeObserver(this);
}
}
APPLOVIN SDK KEY SETTING #
"app_lovin": {
"sdk_key": "l2eT38yPMONBdyKO3A",
"is_unlimited_ads": false,
"id_unit_banner": "def1da1bf25084e",
"id_unit_intra": "9657b7aa7d1430b",
"id_unit_native_multiple":
{
"small":"1d7452a63e76862",
"medium":"f330bac72f3dbf9",
"manual":"42a7734a713d7f5"
},
"rewared_ads_unit_id": "deda40e3d0a2840",
"is_banner_ads": true,
"is_interstitial_ads": true,
"is_native_ads": true,
"is_rewared_ads": true
}17
or
```xml
<applicaton ......... >
<meta-data android:name="applovin.sdk.key" android:value="l2eT38yPMONBdyKO3A" />
<meta-data android:name="applovin.sdk.verbose_logging" android:value="true" />
</application>
## JSON Setting
``` dart
{
"com.bitlinks.usa.iptv.m3ulist":
{
"ads_sequence": [
"google_ads"
],
"more_app_url": "https://play.google.com/store/apps/developer?id=Bit+Links",
"extra_url": "https://gitlab.com/bitcodingsolutions/TVGram/-/raw/master/TVGram/Data/USA_Live.json",
"iptv_player_url": "com.pocketiptv",
"ad_setting": {
"app_version_code": 1,
"is_full_ads": false,
"onesignal_id": "07de0128-c4bc-45f0-8baa-6867a262a6b7",
"ads_loading_text": "Ads will loading...",
"global_intra_interval_click": 1,
"interstitial_ad_time_interval": 0
},
"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."
},
"exit_dialog": {
"is_exit_require": true,
"exit_title": "Exit",
"exit_message": "Do you want to exit from App?"
},
"reward_dialog": {
"is_reward_require": true,
"reward_message": "Watch Reward ads for get TV Channel list"
},
"About_App": {
"is_override": false,
"is_about_app": true,
"about_title": "USA IPTV Links m3u Playlists",
"about_message": "Your app need an Update!",
"registration_detail": "USA IPTV Links m3u Playlists",
"version_detail": "version : 1.0.0"
},
"rate_app": {
"is_rate_app": true,
"package_id": "com.bitlinks.usa.iptv.m3ulist",
"rate_app_url": "https://play.google.com/store/apps/details?id=com.bitlinks.usa.iptv.m3ulist",
"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.bitlinks.usa.iptv.m3ulist",
"share_message": "Now anyone can get USA IPTV Links m3u Playlists app : https://play.google.com/store/apps/details?id=com.bitlinks.usa.iptv.m3ulist"
},
"privacy_policy": {
"is_privacy_policy": true,
"is_system_browser": true,
"privacy_policy": "https://pages.flycricket.io/usa-iptv-links-m3u-p-0/privacy.html"
},
"terms_of_use": {
"is_terms_of_use": true,
"is_system_browser": true,
"terms_of_use": "https://pages.flycricket.io/usa-iptv-links-m3u-p-0/privacy.html"
},
"error_report": {
"is_error_report_support": true,
"email_id": "mailto:bitlinks.llc@gmail.com"
},
"feedback_support": {
"is_feedback_support": true,
"email_id":"mailto:bitlinks.llc@gmail.com",
"feedback_title": "Feedback on USA IPTV Links m3u Playlists",
"feedback_message": "Hi,\n\n\nYour Feedback USA IPTV Links m3u Playlists! I would like to give you some feedback:",
"email_subject": "Feedback on USA IPTV Links m3u Playlists",
"email_message": "Hi,\n\n\nYour Feedback USA IPTV Links m3u Playlists! 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": "/6499/example/rewarded",
"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": 1
},
"facebook_ads": {
"banner_ad_unit_id_android": "60489247125759_6048928924197",
"interstitial_ad_unit_id_android": "6048924717569_60489931257523",
"rewared_ads_unit_id": "6048924757569_604893267924156",
"native_ads_unit_id_android": "IMG_16_9_APP_INSTALL#YOUR_PLACEMENT_ID",
"is_banner_ads": true,
"is_interstitial_ads": true,
"is_rewared_ads": false,
"is_native_ads": true,
"no_of_click_interstitial": 1
},
"custom_ads": {
"qureka_link": "https://490.go.qureka.com/intro/question",
"is_quraka_banner": true,
"is_quraka_intera": 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_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"
]
},
"app_lovin": {
"is_unlimited_ads": true,
"id_unit_banner": "def1da1bf275084e",
"id_unit_intra": "9657b7aa7df1430b",
"id_unit_native_multiple":
{
"small":"1d7452a663e76862",
"medium":"f330bac72f03dbf9",
"manual":"42a7734a7013d7f5"
},
"rewared_ads_unit_id": "deda40e32d0a2840",
"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
}
}
}