mc_sdk 1.1.0
mc_sdk: ^1.1.0 copied to clipboard
A multi-mediation advertising SDK for Flutter, bridging MAX, AdMob, GroMore and TopOn, with banner, MREC, interstitial, rewarded, app-open and native ad formats.
MCSDK Flutter Plugin #
A multi-mediation advertising SDK for Flutter. mc_sdk bridges the native MCSDK
on Android and iOS, giving you a single Dart API across mediation networks such as
MAX, AdMob, GroMore and TopOn.
Features #
- Ad formats: Banner, MREC, Interstitial, Rewarded, App-Open and Native ads.
- Smart Cache: built-in preloading APIs for interstitial, rewarded and app-open ads.
- Privacy controls: user consent, age-restricted user, and do-not-sell flags.
- Mediation debugger and runtime mediation-switch callbacks.
Documentation #
Check out the HyperBid Flutter integration docs: English · 中文.
Platform support #
| Platform | Minimum version |
|---|---|
| Android | minSdkVersion 16 |
| iOS | 13.0 |
Installation #
Add the dependency to your app's pubspec.yaml:
dependencies:
mc_sdk: ^1.1.0
Then run:
flutter pub get
Native SDK setup is required. This plugin is a bridge to the native MCSDK. Your host app must also integrate the native MCSDK dependencies (Android and iOS) and configure the platform App ID / App Key. Follow the HyperBid Flutter integration guide before using the APIs below.
Usage #
Initialize #
Call initialize once, early in your app's lifecycle:
import 'package:mc_sdk/mc_sdk.dart';
final config = await McSdk.initialize(appId, appKey);
Interstitial #
McSdk.setInterstitialListener(McInterstitialListener(
onAdLoadedCallback: (ad) => print('loaded'),
onAdLoadFailedCallback: (adUnitId, error) => print('failed: ${error.code}'),
onAdDisplayedCallback: (ad) {},
onAdHiddenCallback: (ad) {},
onAdClickedCallback: (ad) {},
));
McSdk.loadInterstitial(interstitialAdUnitId);
if (await McSdk.isInterstitialReady(interstitialAdUnitId) ?? false) {
McSdk.showInterstitial(interstitialAdUnitId);
}
Rewarded #
McSdk.setRewardedAdListener(McRewardedAdListener(
onAdLoadedCallback: (ad) {},
onAdLoadFailedCallback: (adUnitId, error) {},
onAdDisplayedCallback: (ad) {},
onAdClickedCallback: (ad) {},
onAdHiddenCallback: (ad) {},
onAdReceivedRewardCallback: (ad, reward) {},
onAdFailedToReceivedRewardCallback: (ad) {},
));
McSdk.loadRewardedAd(rewardedAdUnitId);
McSdk.showRewardedAd(rewardedAdUnitId);
Banner #
McSdk.setBannerListener(McAdViewAdListener(
onAdLoadedCallback: (ad) {},
onAdLoadFailedCallback: (adUnitId, error) {},
onAdClickedCallback: (ad) {},
));
McSdk.createBanner(bannerAdUnitId, AdViewPosition.bottomCenter);
McSdk.showBanner(bannerAdUnitId);
// ...
McSdk.hideBanner(bannerAdUnitId);
McSdk.destroyBanner(bannerAdUnitId);
Smart Cache #
For automatically preloaded fullscreen ads:
McSdk.setSmartCacheInterstitialListener(/* ... */);
McSdk.smartLoadInterstitial();
if (await McSdk.smartIsInterstitialReady() ?? false) {
McSdk.smartShowInterstitial();
}
Native ads #
Use the McNativeAdView widget exported by the package to render native ads
inside your layout. See the example/ app for a complete integration.
Privacy #
McSdk.setHasUserConsent(true);
McSdk.setIsAgeRestrictedUser(false);
McSdk.setDoNotSell(false);
Example #
A full sample app is available under example/, covering every ad
format and the Smart Cache APIs.
License #
This project is licensed under the GNU General Public License v3.0 — see the LICENSE file for details.