google_applovin_unity_ads 0.0.8 google_applovin_unity_ads: ^0.0.8 copied to clipboard
Ads Implement
Add the dependency in pubspec.yaml
:
PERSONAL PACKAGE #
yaml
dependencies:
... google_applovin_unity_ads: ^0.0.7
ADD ANDROID MANIFEST #
xml
//PERMISSION
//META DATA
FOR ANDROID SPLASH SCREEN
BUILD GRADLE #
xml
multiDexEnabled true
targetSdkVersion 33
android:usesCleartextTraffic="true"
ADD MAIN.DART #
dart
WidgetsFlutterBinding.ensureInitialized();
await APICALLINGMETHOD();
if ((apiModel?.comIptvM3UPlaylists ?? "").toString().isNotEmpty) {
GoogleApplovinUnityAds.initialize(
jsonEncode(apiModel?.comIptvM3UPlaylists).toString(),
callback: () => {runApp(const IPTV())});
}
ADD VERSION CODE FUNCTION
yaml
dependencies:
package_info_plus:
dart
int versionCode = 1;
PackageInfo packageInfo = await PackageInfo.fromPlatform();
setState(() {
versionCode = int.parse(packageInfo.buildNumber);
print("11111111- ${versionCode}");
});
ADS_FILE.DART #
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 = null}) async {
if (apiModel!.comIptvM3UPlaylists.adSetting.appVersionCode == versionCode) {
if (callback != null) {
callback();
}
} else {
GoogleApplovinUnityAds.showIntraAds(callback: callback);
}
}
Future
bannerAds() {
print(" palsana ${apiModel!.comIptvM3UPlaylists.adSetting.appVersionCode}");
print(" palsana ${versionCode}");
if (apiModel!.comIptvM3UPlaylists.adSetting.appVersionCode == versionCode ||
apiModel!.comIptvM3UPlaylists.adsSequence.isEmpty) {
return Container(
height: 0,
);
}
return GoogleApplovinUnityAds.bannerAds();
}
fullNativeAds() {
if (apiModel!.comIptvM3UPlaylists.adSetting.appVersionCode == versionCode ||
apiModel!.comIptvM3UPlaylists.adsSequence.isEmpty ||
(apiModel!.comIptvM3UPlaylists.adsSequence.length == 1 &&
apiModel!.comIptvM3UPlaylists.adsSequence[0] == "custom_ads")) {
return Container(
height: 0,
);
}
return GoogleApplovinUnityAds.nativeAds(
NativeSize(Size(double.infinity, 50.h)), "F",
error: Container(
height: 0,
));
}
mediumNativeAds() {
if (apiModel!.comIptvM3UPlaylists.adSetting.appVersionCode == versionCode ||
apiModel!.comIptvM3UPlaylists.adsSequence.isEmpty ||
(apiModel!.comIptvM3UPlaylists.adsSequence.length == 1 &&
apiModel!.comIptvM3UPlaylists.adsSequence[0] == "custom_ads")) {
return Container(
height: 0,
);
}
return GoogleApplovinUnityAds.nativeAds(
NativeSize(Size(double.infinity, 25.h)), "M");
}
showOpenAd() {
if (apiModel!.comIptvM3UPlaylists.adSetting.appVersionCode == versionCode ||
apiModel!.comIptvM3UPlaylists.adsSequence.isEmpty) {
return;
}
GoogleApplovinUnityAds.showOpenAds();
}
smallNativeAds() {
if (apiModel!.comIptvM3UPlaylists.adSetting.appVersionCode == versionCode ||
apiModel!.comIptvM3UPlaylists.adsSequence.isEmpty ||
(apiModel!.comIptvM3UPlaylists.adsSequence.length == 1 &&
apiModel!.comIptvM3UPlaylists.adsSequence[0] == "custom_ads")) {
return Container(
height: 0,
);
}
return GoogleApplovinUnityAds.nativeAds(
NativeSize(Size(double.infinity, 50.h)), "S");
}
class nativeAdsClass {}