Flutter Integration

1. Installation

Install the plugin by running this command in the console.

				
					flutter pub add yodo1mas
				
			

2. Android setup

2.1 Add Admob ID in AndroidManifest.xml which can be found under Android > src > main folder.

				
					<meta-data
   android:name="com.google.android.gms.ads.APPLICATION_ID"
   android:value="Your Admob ID"/>
				
			

Make sure to add this code inside tag.

You can find your Admob ID in MAS dashboard.

2.2 You need to add the following lines in build.gradle app level in the buildtypes release section.

				
					minifyEnabled false
shrinkResources false
				
			

2.3 Then add the following line in build.gradle app level in the default config section.

				
					multiDexEnabled true
				
			

3. iOS setup

3.1 Add the following lines into your Podfile.

				
					source 'https://github.com/CocoaPods/Specs.git'
source 'https://github.com/Yodo1Games/MAS-Spec.git'
source 'https://github.com/Yodo1Games/Yodo1Spec.git'
				
			

3.2 Set the target version to minimum 11.

				
					platform :ios, '11.0'
				
			

3.3 Check this link and complete Step 2.

4. Initialization

4.1 Import the following library in main.dart

				
					import 'package:yodo1mas/testmasfluttersdktwo.dart';
				
			

4.2 Initialize the SDK

				
					Yodo1MAS.instance.init("Your appkey", true,(successful) {
});
				
			

The init() method support 2 parameters:

  • The first one is your appkey
  • The second one is a bool to enable/disable the privacy dialog

5. Banner ads

You can call a banner using this widget.

				
					Yodo1MASBannerAd(
 size: BannerSize.Banner,
 onLoad: () => print('Banner loaded:'),
 onOpen: () => print('Banner clicked:'),
 onClosed: () => print('Banner clicked:'),
 onLoadFailed: (message) =>
     print('Banner Ad $message'),
 onOpenFailed: (message) =>
     print('Banner Ad $message'),
),

				
			

From the BannerSize class you can select different sizes.

You need to contact your CSM if you want to use non standard banners.

6. Interstitial ads

6.1. Set the callbacks

				
					Yodo1MAS.instance.setInterstitialListener((event, message) {
switch(event) {
case Yodo1MAS.AD_EVENT_OPENED:
print('Interstitial AD_EVENT_OPENED');
break;
case Yodo1MAS.AD_EVENT_ERROR:
print('Interstitial AD_EVENT_ERROR' + message);
break;
case Yodo1MAS.AD_EVENT_CLOSED:
print('Interstitial AD_EVENT_CLOSED');
break;
}});

				
			

6.2 Show the ads

				
					Yodo1MAS.instance.showInterstitialAd();
				
			

7. Rewarded ads

7.1 Set the callbacks

				
					Yodo1MAS.instance.setRewardListener((event, message) {
switch(event) {
case Yodo1MAS.AD_EVENT_OPENED:
print('RewardVideo AD_EVENT_OPENED');
break;
case Yodo1MAS.AD_EVENT_ERROR:
print('RewardVideo AD_EVENT_ERROR' + message);
break;
case Yodo1MAS.AD_EVENT_CLOSED:
print('RewardVideo AD_EVENT_CLOSED');
break;
case Yodo1MAS.AD_EVENT_EARNED:
print('RewardVideo AD_EVENT_EARNED');
break;
}});

				
			

7.2 Show the ads

				
					Yodo1MAS.instance.showRewardAd();
				
			

8. Native ads

				
					Yodo1MASNativeAd(
    size: NativeSize.NativeLarge,
    backgroundColor: "BLACK",
    onLoad: () => print('Native Ad loaded:'),
    onClosed: () => print('Native Ad clicked:'),
    onLoadFailed: (message) =>
    print('Native Ad $message'),
),

				
			

From the NativeSize class, you can select different sizes: NativeSmall (3:1) and NativeLarge(6:5), you also need to select the same size in MAS dashboard in your game settings.

backgroundColor: This parameter is used to set a color to native ad background, you can remove this parameter in order to set the background color as transparent.

8. ProGuard

If you’re using ProGuard, add the following code to your ProGuard file (Android Studio: proguard-rules.pro or Eclipse: proguard-project.txt): Download the file here.

For the next step, please test your integration.

CONTENTS