vmax_flutter
VmaxFlutter SDK allows the publishers to display wide variety of ads.
Getting Started
Prerequisites for iOS
- Use Xcode 13.3.1 or higher
- Target iOS 12.0 or higher
Prerequisites for Android
Add below entry in AndroidManifest.xml
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-3940256099942544~3347511713" />
Initialize VmaxFlutterManager
It's the first & foremost step in VmaxFlutter SDK. Publishers need to initialize the VmaxFlutterManager class before making an ad request.
To initialize VmaxFlutterManager you need to register with Vmax & generate an accountId, appId & secretKey from the Vmax Console
Before Initializing the VmaxFlutterManager developer needs to initialize VmaxFlutterUser first & pass user-specific targeting information. User-related parameters like id, gender, age, city, region, country, zip-code & keywords that can be used for custom targeting:
VmaxFlutterUser vmaxUser = VmaxFlutterUser.instance;
vmaxUser.setId("USER_ID");
vmaxUser.setGender("USER_GENDER");
vmaxUser.setAge("USER_AGE");
vmaxUser.setCity("USER_CITY");
vmaxUser.setRegion("USER_REGION");
vmaxUser.setCountry("USER_COUNTRY");
vmaxUser.setZipCode("USER_ZIPCODE");
vmaxUser.setKeywords(["USER_KEYWORD"]);
Now use the appId, accountId & secretKey in VmaxFlutterManager initialize(accountId:, appId:, secretKey:, listener:) method to set up the VmaxFlutter SDK. Use InitializationStatusListener for relevant Initialization status.
Initializing VmaxFlutter library will validate the appId, get targeting data for users using accountId & secretKey, and fetch the user-agent, IDFA, and device information used in every subsequent ad request.
VmaxFlutterManager.instance.initialize(accountId: ACCOUNT_ID, appId: APP_ID, secretKey: "SECRET_KEY", listener: InitializationStatusListener(
onSuccess: (){
print("VmaxManager Initialization Success");
},
onFailure: (){
print("VmaxManager Initialization Failed");
})
);
Create AdSpace
VmaxFlutterAdSpace represents a space reserved for displaying a single ad. Developers can use this space to display a wide variety of ads.
To display an ad you need to create TAG_ID from the Vmax console and then use it to monetize the adSpace.
Developers need to listen for VmaxFlutterAdSpaceListener which tells them the current state of the adSpace.
To create VmaxFlutterAdSpace follow these steps to create one:
NOTE:- VmaxFlutterManager InitializationStatusListener status should be successful before creating a VmaxFlutterAdSpace.
- Create an instance of VmaxFlutterAdSpace by providing tagId & registering VmaxFlutterAdSpaceListener in the constructor of VmaxFlutterAdSpace.
VmaxFlutterAdSpace _adSpace = VmaxFlutterAdSpace(tagId: "TAG_ID", listener: VmaxFlutterAdSpaceListener(
onAdReady: () {
print("VmaxFlutterAdSpace onAdReady");
},
onAdRender: (){
print("VmaxFlutterAdSpace onAdRender");
},
onAdError: () {
print("VmaxFlutterAdSpace onAdError");
},
onAdClick: (){
print("VmaxFlutterAdSpace onAdClick");
})
);
-
After creating a VmaxFlutterAdSpace, you need to call the
cacheAd()to send an ad request to the Vmax server. -
When you receive a callback from
onAdReadyfromVmaxFlutterAdSpaceListeneruse theVmaxWidgetclass & pass the VmaxFlutterAdSpace object in them.
VmaxWidget(adSpace: _adSpace)
What is VmaxWidget?
VmaxWidget displays a VmaxFlutterAdSpace as a Flutter widget.
The developer must call the cacheAd() before showing the widget. Otherwise, a PlatformException will be thrown.