Getting Started
Overview
The AdWangmaiSDK is a robust framework that allows mobile app developers to incorporate advertisements seamlessly into their applications. By doing so, developers can monetize their apps and generate revenue through ad placements.
Prerequisites
- A registered account on AdWangmaiSDK
- An iOS or Android application project
- A compatible development environment (Xcode for iOS, Android Studio for Android)
Installation
- Download the latest version of the AdWangmaiSDK from the official website.
- Extract the downloaded file.
- For iOS:
- Drag and drop the AdWangmaiSDK framework to your Xcode project.
- Make sure that the framework is added to both the “Linked Frameworks and Libraries” and “Embedded Binaries” sections of your project settings.
- For Android:
- Copy the AdWangmaiSDK library folder to your Android project’s “libs” directory.
- Add the following dependencies to your project’s Gradle file:
- implementation files(‘libs/AdWangmaiSDK.jar’)
- implementation ‘com.google.android.gms:play-services-ads:19.8.0’
Integration
Ad Unit ID
Before you can start displaying ads, you need to obtain a unique Ad Unit ID from the AdWangmaiSDK platform. This ID identifies the specific ad unit within your application where ads will be displayed. Refer to the AdWangmaiSDK documentation on how to create and manage ad units.
Initialization
Initialize the AdWangmaiSDK in your app’s main activity or entry point. For iOS, add the following code snippet to your AppDelegate file:
// Swift
import AdWangmaiSDK
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
AdWangmaiSDK.initialize()
return true
}
For Android, add the following code snippet to your MainActivity file:
// Java
import com.adwangmai.sdk.AdWangmaiSDK;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
AdWangmaiSDK.initialize(this);
}
}
Loading Ads
To display ads, you need to load them from the AdWangmaiSDK platform. Here’s an example of how to load a banner ad:
// Swift
import AdWangmaiSDK
let bannerAd = AdWangmaiSDK.BannerAd(unitId: "YOUR_AD_UNIT_ID")
bannerAd.delegate = self
bannerAd.loadAd()
For Android:
// Java
import com.adwangmai.sdk.AdWangmaiSDK;
import com.adwangmai.sdk.ads.BannerAd;
BannerAd bannerAd = new BannerAd(MainActivity.this, "YOUR_AD_UNIT_ID");
bannerAd.setAdListener(new AdListener() {
@Override
public void onAdLoaded() {
// Banner ad loaded successfully.
}
@Override
public void onAdFailedToLoad(int errorCode) {
// Banner ad failed to load.
}
});
bannerAd.loadAd();
Displaying Ads
Once an ad is loaded successfully, you can display it in your app’s UI. Here’s an example for showing a banner ad:
// Swift
import AdWangmaiSDK
func adViewDidReceiveAd(_ adView: GADBannerView) {
// Ad successfully received, display the banner ad view.
bannerAdView.rootViewController = self
self.view.addSubview(bannerAdView)
}
For Android:
// Java
import com.adwangmai.sdk.ads.BannerAd;
bannerAdView.setAdListener(new AdListener() {
@Override
public void onAdLoaded() {
// Ad successfully received, display the banner ad view.
bannerAdView.setVisibility(View.VISIBLE);
}
@Override
public void onAdFailedToLoad(int errorCode) {
// Banner ad failed to load.
}
});
layout.addView(bannerAdView);
Additional Functionality
Interstitial Ads
The AdWangmaiSDK also supports interstitial ads, which are full-screen ads that appear at natural transition points during app usage. To integrate interstitial ads into your app, follow these steps:
- Create an InterstitialAd instance by providing the appropriate Ad Unit ID.
- Implement the necessary delegate methods to handle successful loading and displaying of interstitial ads.
- Load an interstitial ad using the loadAd() method.
- Display the ad using the showAd() method.
- Handle delegate methods for ad closure and user interaction.
Rewarded Video Ads
Rewarded video ads are a popular ad format that allows users to opt-in and watch a video ad in exchange for in-app rewards or bonuses. To integrate rewarded video ads in your app:
- Initialize the AdWangmaiSDK, as mentioned in the “Initialization” section.
- Create a RewardedAd instance and set it up with the appropriate Ad Unit ID.
- Load a rewarded video ad using the loadAd() method.
- Implement delegate methods to handle successful ad load and displaying.
- Display the rewarded video ad to the user at an appropriate time.
- Handle reward issuance and user interaction through delegate methods.
Reporting and Analytics
Event Tracking
The AdWangmaiSDK provides comprehensive event tracking capabilities to help you analyze and optimize your ad performance. You can track events such as ad impressions, clicks, and user engagement. Refer to the AdWangmaiSDK documentation for detailed information on implementing event tracking.
Reporting API
AdWangmaiSDK offers a robust reporting API that allows you to retrieve detailed performance data for your ad units programmatically. This data can be utilized for custom reporting, data analysis, and performance optimization. The Reporting API documentation provides detailed information on available endpoints and request parameters.
Best Practices
- Follow ad placement guidelines to optimize user experience and maximize revenue.
- Test different ad formats and placements to find the most effective monetization strategy.
- Regularly monitor and analyze ad performance to identify areas for improvement.
- Keep up with the latest AdWangmaiSDK updates and features to leverage new monetization opportunities.
Conclusion
This comprehensive guide has provided you with the necessary information to get started with the AdWangmaiSDK and integrate advertisements into your mobile applications. By leveraging the features and functionalities offered by the AdWangmaiSDK, you can effectively monetize your apps and generate revenue through ad placements. Remember to optimize your ad strategy, track performance, and stay updated with the latest SDK enhancements to maximize your monetization potential.