google_applovin_unity_ads 0.0.9 google_applovin_unity_ads: ^0.0.9 copied to clipboard
Ads Implement
Add the dependency in pubspec.yaml
:
PERSONAL PACKAGE #
dependencies:
... google_applovin_unity_ads: ^0.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
<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" />
BUILD GRADLE #
multiDexEnabled true
targetSdkVersion 33
android:usesCleartextTraffic="true"
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 = null}) async {
if (apiModel!.comIptvM3UPlaylists.adSetting.appVersionCode == versionCode) {
if (callback != null) {
callback();
}
} else {
GoogleApplovinUnityAds.showIntraAds(callback: callback);
}
}
Future<void> showRewardAds({Function? callback}) async {
if (apiModel!.comIptvM3UPlaylists.adSetting.appVersionCode == versionCode) {
if (callback != null) {
callback();
}
} else {
GoogleApplovinUnityAds.showRewardAds(callback: callback);
}
}
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 {}