appvestor_billing_stats 1.0.13 copy "appvestor_billing_stats: ^1.0.13" to clipboard
appvestor_billing_stats: ^1.0.13 copied to clipboard

Flutter SDK wrapper for Appvestor Android and iOS stats framework

example/lib/main.dart

import 'dart:io';

import 'package:appvestor_billing_stats/ads/ad_format.dart' as billingAdFormat;
import 'package:appvestor_billing_stats/ads/ad_impression_provider.dart';
import 'package:appvestor_billing_stats/ads/applovin_ad_provider.dart';
import 'package:appvestor_billing_stats/ads/custom_ad_provider.dart';
import 'package:appvestor_billing_stats/ads/google_ad_provider.dart';
import 'package:appvestor_billing_stats/appvestor_billing_stats.dart';
import 'package:appvestor_billing_stats/attribution/attribution_data_type.dart';
import 'package:appvestor_billing_stats/events/events.dart';
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:applovin_max/applovin_max.dart';
import 'package:purchases_flutter/purchases_flutter.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Appvestor Stats Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
      ),
      home: const MyHomePage(title: 'Appvestor Stats SDK Demo'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {

  @override @override
  void initState() {
    super.initState();
    AppvestorBillingStats.initialize();
    AppvestorBillingStats.setAcID(acId: "your_account_id");
    AppvestorBillingStats.setApId(apId: "your_ap_id");
    // PurchasesConfiguration configuration = PurchasesConfiguration(<public_sdk_key>);
    // configuration.purchasesAreCompletedBy = PurchasesAreCompletedByMyApp(
    //   storeKitVersion: StoreKitVersion.storeKit2,
    // );
    // Purchases.configure(configuration);
    AppvestorBillingStats.firebaseEvents.listen((event) {
      debugPrint(
        "🔥 Appvestor Firebase Event: ${event['eventName']} -> ${event['payload']}",
      );
    });
    AppvestorBillingStats.dispatchAdImpressionAppLovin(AppLovinImpressionProvider(adUnitId: "ueid", adRevenue: 3.0, adFormat: "Banner", precision: "rffjk", networkName: "Applovin"));
    AppvestorBillingStats.dispatchAdImpressionGoogleAds(GoogleAdImpressionProvider(adUnitId: "tgj", valueMicros: 10, adFormat: billingAdFormat.AdFormat.banner, currencyCode: "USD", precisionType: 2, adSourceName: "Google"));
    AppvestorBillingStats.dispatchAdImpressionCustom(CustomAdImpressionProvider(adUnitId: "fjnhjg", value: 4.9, adFormat: billingAdFormat.AdFormat.banner, currencyCode: "EUR", precisionType: "djfh", adSourceName: "Custom"));
  }

  Widget _buildButton(String title, VoidCallback onPressed) {
    return Padding(
      padding: const EdgeInsets.symmetric(vertical: 4),
      child: ElevatedButton(onPressed: onPressed, child: Text(title)),
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
      ),
      body: SingleChildScrollView(
        padding: const EdgeInsets.all(16),
        child: Center(
          child: Column(
            children: <Widget>[
              const SizedBox(height: 20),

              _buildButton("Dispatch Internal Event", () {
                AppvestorBillingStats.dispatchEvent(
                  eventName: InternalEventKey.AD_CLICKED,
                  optionalParams: {'source': 'flutter_app'},
                );
              }),

              _buildButton("Dispatch Ad Viewed", () {
                AppvestorBillingStats.dispatchAdViewedEvent("banner_home");
              }),

              _buildButton("Dispatch Ad Clicked", () {
                AppvestorBillingStats.dispatchAdClickedEvent("banner_home");
              }),

              _buildButton("Dispatch Revenue Event", () {
                AppvestorBillingStats.dispatchCustomRevenueEvent(
                  eventName: "purchase_made",
                  value: 4.99,
                  currency: "USD",
                );
              }),

              _buildButton("Dispatch Ad Impression", () {
                AppvestorBillingStats.dispatchAdImpressionEvent(
                  value: 1.2,
                  currency: "USD",
                  adPlatform: AdImpressionProvider.GAM,
                );
              }),

              _buildButton("Dispatch Attribution Data", () {
                AppvestorBillingStats.dispatchAttributionData(
                  type: AttributionDataType.DEFERRED_DEEP_LINK,
                  data: {
                    'tracker_token': 'abc123',
                    'campaign': 'spring_launch',
                  },
                );
              }),

              _buildButton("Report Purchase", () {
                AppvestorBillingStats.reportPurchase(
                  '{"orderId":"GPA.1111-2222-3333-44444"}',
                );
              }),
            ],
          ),
        ),
      ),
    );
  }
}






//
//
// import 'dart:io';
//
// import 'package:appvestor_billing_stats/ads/ad_format.dart' as billingAdFormat;
// import 'package:appvestor_billing_stats/ads/ad_impression_provider.dart';
// import 'package:appvestor_billing_stats/ads/applovin_ad_provider.dart';
// import 'package:appvestor_billing_stats/ads/custom_ad_provider.dart';
// import 'package:appvestor_billing_stats/ads/google_ad_provider.dart';
// import 'package:appvestor_billing_stats/appvestor_billing_stats.dart';
// import 'package:appvestor_billing_stats/attribution/attribution_data_type.dart';
// import 'package:appvestor_billing_stats/events/events.dart';
// import 'package:flutter/material.dart';
// import 'dart:async';
// import 'package:applovin_max/applovin_max.dart';
// import 'package:google_mobile_ads/google_mobile_ads.dart';
//
// void main() {
//   runApp(const MyApp());
// }
//
// class MyApp extends StatelessWidget {
//   const MyApp({super.key});
//
//   @override
//   Widget build(BuildContext context) {
//     return MaterialApp(
//       title: 'Appvestor Stats Demo',
//       theme: ThemeData(
//         colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
//       ),
//       home: const MyHomePage(title: 'Appvestor Stats SDK Demo'),
//     );
//   }
// }
//
// class MyHomePage extends StatefulWidget {
//   const MyHomePage({super.key, required this.title});
//
//   final String title;
//
//   @override
//   State<MyHomePage> createState() => _MyHomePageState();
// }
//
// class _MyHomePageState extends State<MyHomePage> {
//
//   _bannerAd = BannerAd(
//   adUnitId: "google ad unit",
//   request: const AdRequest(),
//   size: AdSize.banner,
//   listener: BannerAdListener(
//   onAdLoaded: (ad) {
//   AppvestorBillingStats.dispatchAdViewedEvent(adUnit);
//   },
//   onAdFailedToLoad: (ad, error) {
//   ad.dispose();
//   },
//   onAdOpened: (ad) {
//   },
//   onAdClosed: (ad) {
//   },
//
//   onAdImpression: (ad) {
//   ad.
//   },
//   onAdClicked: (ad) {
//   },
//   ),
//   );
//
//
//
//   @override
//   Future<void> initState()  {
//   super.initState();
//   AppvestorBillingStats.initialize();
//   AppvestorBillingStats.setAcID(acId: "jfkl");
//   AppvestorBillingStats.setApId(apId: "dhfjkjhgf");
//   AppvestorBillingStats.firebaseEvents.listen((event) {
//   debugPrint(
//   "🔥 Appvestor Firebase Event: ${event['eventName']} -> ${event['payload']}",
//   );
//   });
//   MaxConfiguration? sdkConfiguration = AppLovinMAX.initialize("fbhjkf").then(onValue){
//
//   };
//   AppvestorBillingStats.dispatchCustomRevenueEvent(eventName: eventName);
//   AppvestorBillingStats.dispatchAdImpressionAppLovin(AppLovinImpressionProvider(adUnitId: "ueid", adRevenue: 3.0, adFormat: "oioyjy", precision: "rffjk", networkName: "Applovin"));
//   AppvestorBillingStats.dispatchAdImpressionGoogleAds(GoogleAdImpressionProvider(adUnitId: "tgj", valueMicros: 10, adFormat: billingAdFormat.AdFormat.banner, currencyCode: "USD", precisionType: 2, adSourceName: "Google"));
//   AppvestorBillingStats.dispatchAdImpressionCustom(CustomAdImpressionProvider(adUnitId: "fjnhjg", value: 4.9, adFormat: billingAdFormat.AdFormat.banner, currencyCode: "EUR", precisionType: "djfh", adSourceName: "Custom"));
//   }
//
//   Widget _buildButton(String title, VoidCallback onPressed) {
//   return Padding(
//   padding: const EdgeInsets.symmetric(vertical: 4),
//   child: ElevatedButton(onPressed: onPressed, child: Text(title)),
//   );
//   }
//
//   @override
//   Widget build(BuildContext context) {
//   return Scaffold(
//   appBar: AppBar(
//   title: Text(widget.title),
//   backgroundColor: Theme.of(context).colorScheme.inversePrimary,
//   ),
//   body: Container(
//   margin: const EdgeInsets.all(8.0),
//   height: 300,
//   child: MaxNativeAdView(
//   adUnitId: "Dummy_ad_unitjanhhwgteyusilmns",
//   controller: null,
//   listener: NativeAdListener(onAdLoadedCallback: (ad) {
//
//   AppvestorBillingStats.dispatchAdImpressionAppLovin(AppLovinImpressionProvider(adUnitId: ad.adUnitId, adRevenue: ad.revenue, adFormat: ad.adFormat, precision: ad.revenuePrecision, networkName: ad.networkName));
//
//   }, onAdLoadFailedCallback: (adUnitId, error) {
//   }, onAdClickedCallback: (ad) {
//   }, onAdRevenuePaidCallback: (ad) {
//   }),
//   child: Container(
//   color: const Color(0xffefefef),
//   padding: const EdgeInsets.all(8.0),
//   ),
//   ),
//   ),
//   );
//   }
// }
//
// final String _interstitial_ad_unit_ID = Platform.isAndroid ? "«Android-ad-unit-ID»" : "«iOS-ad-unit-ID»";
// const int _maxExponentialRetryCount = 6;
// var _interstitialRetryAttempt = 0;
//
// void initializeInterstitialAds() {
//
//   AppLovinMAX.setInterstitialListener(InterstitialListener(
//     onAdLoadedCallback: (ad) {
//
//     },
//     onAdRevenuePaidCallback: (ad){
//       AppvestorBillingStats.dispatchAdImpressionAppLovin(AppLovinImpressionProvider(adUnitId: ad.adUnitId, adRevenue: ad.revenue, adFormat: ad.adFormat, precision: ad.revenuePrecision, networkName: ad.networkName));
//
//     },
//     onAdLoadFailedCallback: (adUnitId, error) {
//
//     },
//     onAdDisplayedCallback: (ad) {
//
//     },
//     onAdDisplayFailedCallback: (ad, error) {
//
//     },
//     onAdClickedCallback: (ad) {
//
//     },
//     onAdHiddenCallback: (ad) {
//
//     },
//   ));
//
//   // Load the first interstitial.
//   AppLovinMAX.loadInterstitial(_interstitial_ad_unit_ID);
// }
1
likes
0
points
260
downloads

Publisher

verified publisherappvestor.com

Weekly Downloads

Flutter SDK wrapper for Appvestor Android and iOS stats framework

Homepage

License

unknown (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on appvestor_billing_stats

Packages that implement appvestor_billing_stats