Skip to main content

Ad Format Integration

Here's how to integrate the supported ad formats in Flutter. Each ad format has its own unique characteristics and implementation details.

Supported Ad Formats

Ad TypeSupportPlugin Constant
App Open AdsYodo1MasFlutterPlugin.adTypeAppOpen
Interstitial AdsYodo1MasFlutterPlugin.adTypeInterstitial
Rewarded AdsYodo1MasFlutterPlugin.adTypeRewarded
Banner AdsYodo1MasFlutterPlugin.adTypeBanner
Native AdsYodo1MasFlutterPlugin.adTypeNative

Ad Events

Ad Events in the SDK are denoted using codes:

Event NameEvent Code
Ad Loaded1004
Ad Failed to Load1005
Ad Opened1001
Ad Closed1002
Ad Failed to Open1003
Reward Earned (Rewarded Only)2001

These constants are available in the SDK through:

import 'package:yodo1_mas_flutter_plugin/constants.dart';

Interstitial Ads

Loading and Showing Ads

// Load an interstitial ad
await yodo1MasFlutterPlugin.loadAd(Yodo1MasFlutterPlugin.adTypeInterstitial);

// Check if ad is loaded
bool isLoaded = await yodo1MasFlutterPlugin.isAdLoaded(Yodo1MasFlutterPlugin.adTypeInterstitial);

// Show the ad
await yodo1MasFlutterPlugin.showAd(Yodo1MasFlutterPlugin.adTypeInterstitial);

Event Handling

_yodo1MasFlutterPlugin.setInterstitialListener((int code, String message) {
switch (code) {
case Yodo1MasConstants.adEventLoaded:
print('Interstitial Ad Loaded: $message');
break;
case Yodo1MasConstants.adEventFailedToLoad:
print('Interstitial Ad Failed to Load: $message');
break;
case Yodo1MasConstants.adEventOpened:
print('Interstitial Ad Opened: $message');
break;
case Yodo1MasConstants.adEventFailedToOpen:
print('Interstitial Ad Failed to Open: $message');
break;
case Yodo1MasConstants.adEventClosed:
print('Interstitial Ad Closed: $message');
break;
}
});

Best Practices

  1. Preload Ads: Always initialize ads during app startup
  2. Error Handling: Implement proper error handling in all callbacks
  3. User Experience: Place ads at natural transition points
  4. Testing: Test thoroughly on both Android and iOS devices
  5. Ad Loading: Check if ads are loaded before showing them