Latest 0.1.3
Homepage https://github.com/pinddFull/RxAdMob
License MIT
Platforms ios 8.0, requires ARC
Dependencies RxSwift, RxCocoa, Google-Mobile-Ads-SDK
Frameworks Foundation
Authors

Build Status
Swift 4.2
Version
Platform
License

RxAdMob is a RxSwift wrapper for GoogleAdMob.

Example Usages (For Interstitial Ads)

Initalize Google AdMob

// Setup API Key on initialize mobile ads
GADMobileAds.configure(withApplicationID: "Your API Key")

Setup

let interstitial = GADInterstitial(adUnitID: "Your UID")
interstitial.load(GADRequest())

Observing properties

interstitial.rx.isReady
    .asDriver(onErrorJustReturn: false)
    .filter { $0 }
    .drive(onNext: { _ in
        interstitial.present(fromRootViewController: self)
    })
    .disposeBag(by: disposeBag)

Delegates

// func interstitialWillDismissScreen(_ ad: GADInterstitial)
interstitial.rx.interstitialDidDismissScreen
    .asDriver()
    .drive(onNext: { interstitial in
        interstitial.load(GADRequest())
    })
    .disposed(by: disposeBag)

// interstitial(_ ad: GADInterstitial, didFailToReceiveAdWithError error: GADRequestError)
interstitial.rx.didFailToReceiveAdWithError
    .asDriver()
    .drive(onNext: { interstitial, error in
        print("Interstitial did fail to receive error: (error.description)")
    })
    .disposed(by: disposeBag)

Installation

CocoaPods

Add to Podfile:

pod 'RxAdMob'

Requirements

Support

GADAdLoader+Rx

public typealias AdLoaderWithError = (adLoader: GADAdLoader, error: Error)
public typealias AdLoaderWithNativeAd = (adLoader: GADAdLoader, nativeAd: GADUnifiedNativeAd)

// Observing Properties
public var adUnitID: Observable<String>
public var isLoading: Observable<Bool>

// Delegate Events
public var adLoaderDidFailToReceiveAdWithError: RxCocoa.ControlEvent<AdLoaderWithError>
public var adLoaderDidReceiveUnifiedNativeAd: RxCocoa.ControlEvent<AdLoaderWithNativeAd>
public var adLoaderDidFinishLoading: RxCocoa.ControlEvent<GADAdLoader>

GADAdReward+Rx

// Observing Properties
public var type: Observable<String>
public var amount: Observable<NSDecimalNumber>

GADBannerView+Rx

public typealias BannerViewWithError = (bannerView: GADBannerView, error: Error)

// Observing Properties
public var adUnitID: Observable<String?>
public var rootViewController: Observable<UIViewController?>
public var adSize: Observable<GADAdSize>
public var adNetworkClassName: Observable<String?>
public var adViewDidReceiveAd: ControlEvent<GADBannerView>

// Delegate Events
public var didFailToReceiveAdWithError: ControlEvent<BannerViewWithError>
public var adViewWillPresentScreen: ControlEvent<GADBannerView>
public var adViewWillDismissScreen: ControlEvent<GADBannerView>
public var adViewDidDismissScreen: ControlEvent<GADBannerView>
public var adViewWillLeaveApplication: ControlEvent<GADBannerView>

GADInterstitial+Rx

public typealias InterstitialWithError = (interstitial: GADInterstitial, error: Error)

// Observing Properties
public var adUnitID: Observable<String?>
public var isReady: Observable<Bool>
public var hasBeenUsed: Observable<Bool>
public var adNetworkClassName: Observable<String?>

// Delegate Events
public var interstitialDidReceiveAd: ControlEvent<GADInterstitial>
public var didFailToReceiveAdWithError: ControlEvent<InterstitialWithError>
public var interstitialWillPresentScreen: ControlEvent<GADInterstitial>
public var interstitialWillDismissScreen: ControlEvent<GADInterstitial>
public var interstitialDidDismissScreen: ControlEvent<GADInterstitial>
public var interstitialWillLeaveApplication: ControlEvent<GADInterstitial>

GADRewardBasedVideoAd+Rx

public typealias RewardBasedVideoAdWithReward = (rewardBasedVideoAd: GADRewardBasedVideoAd, reward: GADAdReward)
public typealias RewardBasedVideoAdWithError = (rewardBasedVideoAd: GADRewardBasedVideoAd, error: Error)

// Observing Properties
public var isReady: Observable<Bool>
public var adNetworkClassName: Observable<String?>
public var userIdentifier: Observable<String?>

// Delegate Events
public var didRewardUser: ControlEvent<RewardBasedVideoAdWithReward>
public var rewardBasedVideoAdDidReceive: ControlEvent<GADRewardBasedVideoAd>
public var rewardBasedVideoAdDidOpen: ControlEvent<GADRewardBasedVideoAd>
public var rewardBasedVideoAdDidStartPlaying: ControlEvent<GADRewardBasedVideoAd>
public var rewardBasedVideoAdDidCompletePlaying: ControlEvent<GADRewardBasedVideoAd>
public var rewardBasedVideoAdDidClose: ControlEvent<GADRewardBasedVideoAd>
public var rewardBasedVideoAdWillLeaveApplication: ControlEvent<GADRewardBasedVideoAd>
public var didFailToLoadWithError: ControlEvent<RewardBasedVideoAdWithError>

GADUnifiedNativeAd+Rx

public typealias RewardBasedVideoAdWithReward = (rewardBasedVideoAd: GADRewardBasedVideoAd, reward: GADAdReward)
public typealias RewardBasedVideoAdWithError = (rewardBasedVideoAd: GADRewardBasedVideoAd, error: Error)

// Observing Properties
public var isReady: Observable<Bool>
public var adNetworkClassName: Observable<String?>
public var userIdentifier: Observable<String?>

// Delegate Events
public var didRewardUser: ControlEvent<RewardBasedVideoAdWithReward>
public var rewardBasedVideoAdDidReceive: ControlEvent<GADRewardBasedVideoAd>
public var rewardBasedVideoAdDidOpen: ControlEvent<GADRewardBasedVideoAd>
public var rewardBasedVideoAdDidStartPlaying: ControlEvent<GADRewardBasedVideoAd>
public var rewardBasedVideoAdDidCompletePlaying: ControlEvent<GADRewardBasedVideoAd>
public var rewardBasedVideoAdDidClose: ControlEvent<GADRewardBasedVideoAd>
public var rewardBasedVideoAdWillLeaveApplication: ControlEvent<GADRewardBasedVideoAd>
public var didFailToLoadWithError: ControlEvent<RewardBasedVideoAdWithError>

GADUnifiedNativeAdView+Rx

// Observing Properties
public var nativeAd: Observable<GADUnifiedNativeAd?>
public var headlineView: Observable<UIView?>
public var callToActionView: Observable<UIView?>
public var iconView: Observable<UIView?>
public var bodyView: Observable<UIView?>
public var storeView: Observable<UIView?>
public var priceView: Observable<UIView?>
public var imageView: Observable<UIView?>
public var starRatingView: Observable<UIView?>
public var advertiserView: Observable<UIView?>
public var mediaView: Observable<GADMediaView?>
public var adChoicesView: Observable<GADAdChoicesView?>

License

MIT License

Latest podspec

{
    "name": "RxAdMob",
    "version": "0.1.3",
    "summary": "RxSwift Wrapper on Google AdMob",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "description": "RxAdMob is a RxSwift wrapper for Google AdMob.",
    "homepage": "https://github.com/pinddFull/RxAdMob",
    "authors": {
        "pinddfull": "[email protected]"
    },
    "source": {
        "git": "https://github.com/pinddFull/RxAdMob.git",
        "tag": "0.1.3"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source_files": [
        "Sources",
        "*.swift"
    ],
    "swift_version": "4.2",
    "requires_arc": true,
    "static_framework": true,
    "frameworks": "Foundation",
    "dependencies": {
        "RxSwift": [
            "~> 4.3"
        ],
        "RxCocoa": [
            "~> 4.3"
        ],
        "Google-Mobile-Ads-SDK": [
            "~> 7.30.0"
        ]
    }
}

Pin It on Pinterest

Share This