XHLaunchAd is a powerful and easy-to-use iOS library that allows you to display launch ads (full screen or banner ads) in your app. It provides a simple way to integrate launch ads into your app, allowing you to monetize your app or show promotional content to your users.
- Easy integration of launch ads in your app.
- Support for both full screen and banner ads.
- Highly customizable ad content and appearance.
- Various ad formats supported, including images and videos.
- Flexible ad display options, such as time duration and display frequency.
- Integration with popular ad networks like Google AdMob.
- Support for targeting specific user demographics or app conditions.
To install XHLaunchAd in your iOS app, follow these steps:
- Ensure that your project meets the following requirements:
- iOS 8.0 or later
- Xcode 12.0 or later
- Swift 4.2 or later
- Open your project in Xcode.
- Using CocoaPods, add the following line to your Podfile:
- Save the Podfile and run
pod install
in the terminal to install the XHLaunchAd library. - Now, you can import the library in your code and start using it.
pod 'XHLaunchAd'
To display launch ads in your app, perform the following steps:
// Import the XHLaunchAd library
import XHLaunchAd
// Initialize the launch ad
XHLaunchAd.setLaunchSourceType(.network)
XHLaunchAd.setWaitDataDuration(3)
XHLaunchAd.show(in: self.window)
You can customize the content and appearance of the launch ads by using the various API provided by XHLaunchAd:
- setWaitDataDuration(_: TimeInterval) // Set the duration to wait for data before showing the ad
- setLoadingImage(_: String) // Set the loading image for remote images or videos
- setLaunchImage(_: String) // Set the default launch image to show while loading the ad
- setVideoAdConfiguration(_: XHLaunchVideoAdConfiguration) // Set the video ad configuration
- setWebImageAdConfiguration(_: XHLaunchImageAdConfiguration) // Set the web image ad configuration
- setAutoSkipAfter(_: TimeInterval) // Set the auto skip duration for full screen ads
...
Handle ad actions such as clicking or closing the ad by implementing the XHLaunchAdDelegate
methods:
class YourViewController: UIViewController, XHLaunchAdDelegate {
override func viewDidLoad() {
super.viewDidLoad()
XHLaunchAd.delegate = self
}
// Handle ad clicking action
func xhLaunchAd(_: XHLaunchAd, clickAndOpenURLString: String) {
// Handle opening the URL in your app
guard let url = URL(string: clickAndOpenURLString) else { return }
UIApplication.shared.open(url, options: [:], completionHandler: nil)
}
// Handle ad closing action
func xhLaunchAd(_: XHLaunchAd, clickAndOpenModel: XHLaunchAdClickAndOpenModel) {
// Handle the corresponding operation according to the ad model
guard let linkType = clickAndOpenModel.openType else { return }
switch linkType {
case .safari:
// Open the URL in Safari
guard let url = clickAndOpenModel.openURL else { return }
UIApplication.shared.open(url, options: [:], completionHandler: nil)
case .app:
// Handle the specific operation for open app type
// ...
case .web:
// Handle the specific operation for open web type
// ...
}
}
}
If you want to integrate Google AdMob to display ads in your app, follow these steps:
- Install the Google Mobile Ads SDK through CocoaPods by adding the following line to your Podfile:
- Initialize the Google Mobile Ads SDK in your app's
AppDelegate
: - Enable AdMob support in XHLaunchAd:
pod 'Google-Mobile-Ads-SDK'
import GoogleMobileAds
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
GADMobileAds.sharedInstance().start(completionHandler: nil)
return true
}
}
XHLaunchAd.setAdMobEnabled(true)
XHLaunchAd is a comprehensive library that simplifies the integration of launch ads in your iOS app. By following the provided guidelines, you can easily monetize your app or promote your content with minimal effort.