admost_flutter_plugin 1.3.3 copy "admost_flutter_plugin: ^1.3.3" to clipboard
admost_flutter_plugin: ^1.3.3 copied to clipboard

Admost Flutter Plugin. Admost is a full-cycle mobile monetization tool with its 3 main functions; Mobile Mediation, Revenue Analytics, and Cross Promotion.

example/lib/main.dart

import 'dart:ffi';

import 'package:flutter/material.dart';
import 'package:admost_flutter_plugin/admost.dart';
import 'package:admost_flutter_plugin/admost_interstitial.dart';
import 'package:admost_flutter_plugin/admost_rewarded.dart';
import 'package:admost_flutter_plugin/admost_ad_events.dart';
import 'package:admost_flutter_plugin/admost_banner.dart';
import 'package:admost_flutter_plugin/admost_banner_size.dart';
import 'package:admost_flutter_plugin/admost_native_ad.dart';
import 'package:admost_flutter_plugin/admost_remote_config.dart';
import 'dart:io';

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  initAdmost();
  runApp(MyApp());

}

Future<void> initAdmost() async {
  //Admost.setCustomVendors({"ADMOST": true, "APPLOVIN": false});
  //Admost.setCanRequestAds(true);
  bool initStatus = await Admost.initialize(
        appId: Platform.isIOS
            ? "15066ddc-9c18-492c-8185-bea7e4c7f88c"
            : "6cc8e89a-b52a-4e9a-bb8c-579f7ec538fe",
        userConsent: "1",
        subjectToGDPR: "1",
        subjectToCCPA: "0");

    print("<ADMOST> init status: ${initStatus}");
    
    remoteConfig();
  //Admost.setUserId("myUniqueUserId");
  //AdmostATTrackingManager.requestTrackingAuthorization().then((value) => print("TrackingAuthorizationStatus: ${value}"));
  //AdmostATTrackingManager.getTrackingAuthorizationStatus().then((value) => print("TrackingAuthorizationStatus: ${value}"));
}

void remoteConfig() async {
  bool? response =
      await AdMostRemoteConfig.getBoolean(key: "isDebug1", defaultValue: true);
  String? response2 = await AdMostRemoteConfig.getString(
      key: "version", defaultValue: "no value");
  num? response3 =
      await AdMostRemoteConfig.getNum(key: "debug", defaultValue: 2.0);
  num? response4 =
      await AdMostRemoteConfig.getNum(key: "doubleValue", defaultValue: 1.0);

  print(
      "<ADMOST> RemoteConfigTest isDebug ${response} / ${response2} / ${response3} / ${response4}");
}

/// This Widget is the main application widget.
class MyApp extends StatelessWidget {
  static const String _title = 'Flutter Code Sample';

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: _title,
      home: Scaffold(
        appBar: AppBar(title: const Text(_title)),
        body: MyHomePage(),
      ),
    );
  }
}

/// This is the stateless widget that the main application instantiates.
class MyHomePage extends StatefulWidget {
  MyHomePage({Key? key}) : super(key: key);

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  String interstitialText = 'Load Interstitial';
  String rewardedText = 'Load Rewarded';

  AdmostInterstitial? interstitialAd;
  AdmostRewarded? rewardAd;
  AdmostBanner? bannerAd;
  AdmostNativeAd? nativeAd;

  @override
  Widget build(BuildContext context) {
    bannerAd = AdmostBanner(
      adUnitId: Platform.isIOS
          ? "b4009772-de04-42c4-bbaa-c18da9e4a1ab"
          : '9fb970db-7d96-4ef2-ac8c-d88ec22270ff',
      adSize: AdmostBannerSize.BANNER,
      listener: (AdmostAdEvent event, Map<String, dynamic> args) {
        if (event == AdmostAdEvent.loaded) {
          print("<ADMOST> Banner Ad network: ${args['network']}");
          print("<ADMOST> Banner Ad ecpm: ${args['ecpm']}");
          print("<ADMOST> Banner Ad Loaded");
        }
        if (event == AdmostAdEvent.clicked) {
          print("<ADMOST> Banner Ad network: ${args['network']}");
          print("<ADMOST> Banner Ad clicked");
        }
        if (event == AdmostAdEvent.failedToLoad) {
          print(
              "<ADMOST> Banner Error description: ${args['errorMessage']}");
          print("<ADMOST Banner Error code: ${args['errorCode']}");
        }
      },
      //optional
      //tag:"YOUR TAG",
    );

    nativeAd = AdmostNativeAd(
      adUnitId: Platform.isIOS
          ? 'c72a4a52-23c5-4c34-9eb1-7bbc4c08c7e4'
          : '951d398e-b6ec-40a7-bc80-6b4b223418df',
      adSize: AdmostBannerSize.MEDIUM_RECTANGLE,
      xibNameForIOS: 'AMRNativeAdBaseView250',
      listener: (AdmostAdEvent event, Map<String, dynamic> args) {
        if (event == AdmostAdEvent.loaded) {
          print("<ADMOST> Native Ad network: ${args['network']}");
          print("<ADMOST> Native Ad ecpm: ${args['ecpm']}");
          print("<ADMOST> Native Ad Loaded");
        }
        if (event == AdmostAdEvent.clicked) {
          print("<ADMOST> Native Ad network: ${args['network']}");
          print("<ADMOST> Native Ad clicked");
        }
        if (event == AdmostAdEvent.failedToLoad) {
          print("<ADMOST> Native Ad Error code: ${args['errorCode']}");
          print(
              "<ADMOST> Native Ad Error description: ${args['errorMessage']}");
        }
      },
      //optional
      //tag:"YOUR TAG",
    );

    return Padding(
      padding: EdgeInsets.all(10),
      child: Center(
        widthFactor: 2,
        heightFactor: 2,
        child: Column(children: <Widget>[
          Card(
            child: InkWell(
              onTap: () {
                Admost.startTestSuite(Platform.isIOS
                    ? "15066ddc-9c18-492c-8185-bea7e4c7f88c"
                    : "6cc8e89a-b52a-4e9a-bb8c-579f7ec538fe");
              },
              child: Center(
                widthFactor: 2,
                heightFactor: 2,
                child: Text("Start Tester Info"),
              ),
            ),
          ),
          Card(
            child: InkWell(
              splashColor: Colors.blue.withAlpha(30),
              onTap: () async {
                if (interstitialAd == null) {
                  interstitialAd = AdmostInterstitial(
                    zoneId: Platform.isIOS
                        ? '39f74377-5682-436a-9338-9d1c4df410bd'
                        : 'f99e409b-f9ab-4a2e-aa9a-4d143e6809ae',
                    listener: (AdmostAdEvent event, Map<String, dynamic> args) {
                      if (event == AdmostAdEvent.loaded) {
                        print("<ADMOST> Interstitial loaded");
                        print(
                            "<ADMOST> Interstitial network: ${args['network']}");
                        print("<ADMOST> Interstitial ecpm: ${args['ecpm']}");
                        interstitialText = 'Show Interstitial';
                        setState(() {
                          interstitialText;
                        });
                      }
                      if (event == AdmostAdEvent.dismissed) {
                        print("<ADMOST> Interstitial dismissed");
                        interstitialText = 'Load Interstitial';
                        setState(() {
                          interstitialText;
                        });
                      }
                      if (event == AdmostAdEvent.opened) {
                        print("<ADMOST> Interstitial Opened");
                      }
                      if (event == AdmostAdEvent.failedToLoad) {
                        print("<ADMOST> Interstitial failedToLoad");
                        print(
                            "<ADMOST> Interstitial Error code: ${args['errorCode']}");
                        print(
                            "<ADMOST> Interstitial Error description: ${args['errorMessage']}");
                      }
                      if (event == AdmostAdEvent.failedToShow) {
                        print("<ADMOST> Interstitial failedToShow");
                        print(
                            "<ADMOST> Interstitial Error code: ${args['errorCode']}");
                        print(
                            "<ADMOST> Interstitial Error description: ${args['errorMessage']}");
                      }
                    },
                  );
                }

                if (await interstitialAd!.isLoaded ?? false) {
                  interstitialAd!.show();
                  // If you want to add tag, you should remove the line above and use the code below (optional)
                  // interstitialAd.show("YOUR TAG");
                } else {
                  interstitialAd!.load();
                }
              },
              child: Center(
                widthFactor: 2,
                heightFactor: 2,
                child: Text(interstitialText),
              ),
            ),
          ),
          Card(
            child: InkWell(
              splashColor: Colors.blue.withAlpha(30),
              onTap: () async {
                if (rewardAd == null) {
                  rewardAd = AdmostRewarded(
                    zoneId: Platform.isIOS
                        ? '2bdefd44-5269-4cbc-b93a-373b74a2f067'
                        : '88cfcfd0-2f8c-4aba-9f36-cc0ac99ab140',
                    listener: (AdmostAdEvent event, Map<String, dynamic> args) {
                      if (event == AdmostAdEvent.loaded) {
                        print("<ADMOST> Rewarded loaded");

                        print("<ADMOST> Rewarded network: ${args['network']}");
                        print("<ADMOST> Rewarded ecpm: ${args['ecpm']}");
                        rewardedText = 'Show Rewarded';
                        setState(() {
                          rewardedText;
                        });
                      } else if (event == AdmostAdEvent.dismissed) {
                        print("<ADMOST> Rewarded dismissed");
                        rewardedText = 'Load Rewarded';
                        setState(() {
                          rewardedText;
                        });
                      } else if (event == AdmostAdEvent.failedToLoad) {
                        print("<ADMOST> Rewarded failedToLoad");
                        print(
                            "<ADMOST> Rewarded Error code: ${args['errorCode']}");
                        print(
                            "<ADMOST> Rewarded Error description: ${args['errorMessage']}");
                      } else if (event == AdmostAdEvent.failedToShow) {
                        print("<ADMOST>  Rewarded failedToShow");
                        print(
                            "<ADMOST> Rewarded Error code: ${args['errorCode']}");
                        print(
                            "<ADMOST> Rewarded Error description: ${args['errorMessage']}");
                      } else if (event == AdmostAdEvent.opened) {
                        print("<ADMOST> Rewarded Opened");
                      } else if (event == AdmostAdEvent.completed) {
                        print("<ADMOST> Rewarded completed");
                      }
                    },
                  );
                }

                if (await rewardAd!.isLoaded ?? false) {
                  rewardAd!.show();
                  // If you want to add tag, you should remove the line above and use the code below (optional)
                  // rewardAd.show("YOUR TAG");
                } else {
                  rewardAd!.load();
                }
              },
              child: Center(
                widthFactor: 2,
                heightFactor: 2,
                child: Text(rewardedText),
              ),
            ),
          ),
          Card(
            child: bannerAd,
          ),
          Card(
            child: nativeAd,
          ),
          Card(
            child: InkWell(
              splashColor: Colors.blue.withAlpha(30),
              onTap: () async {
                nativeAd?.dispose();
              },
              child: Center(
                widthFactor: 2,
                heightFactor: 2,
                child: Text("Dispose Ad"),
              ),
            ),
          )

        ]),
      ),
    );
  }
}
20
likes
130
pub points
77%
popularity

Publisher

verified publisheradmost.com

Admost Flutter Plugin. Admost is a full-cycle mobile monetization tool with its 3 main functions; Mobile Mediation, Revenue Analytics, and Cross Promotion.

Homepage

Documentation

API reference

License

BSD-2-Clause (license)

Dependencies

flutter

More

Packages that depend on admost_flutter_plugin