Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support madu rewarded #20

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 30 additions & 12 deletions iOS/Swift/IronSourceSwiftDemoApp/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -37,31 +37,48 @@
<color key="textColor" systemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" spacing="20" translatesAutoresizingMaskIntoConstraints="NO" id="cl3-aC-wSG" userLabel="Buttons Stack View">
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" spacing="20" translatesAutoresizingMaskIntoConstraints="NO" id="IK7-ly-dwU" userLabel="Buttons Stack View">
<rect key="frame" x="0.0" y="30.5" width="220" height="30"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" enabled="NO" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" showsTouchWhenHighlighted="YES" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="N20-QP-8mE" userLabel="Show Rewarded Video Button">
<rect key="frame" x="0.0" y="0.0" width="220" height="30"/>
<button opaque="NO" contentMode="scaleToFill" enabled="NO" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" showsTouchWhenHighlighted="YES" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="AkV-kT-JiG" userLabel="Load Interstitial Button">
<rect key="frame" x="0.0" y="0.0" width="100" height="30"/>
<constraints>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="100" id="Tq7-jx-vfb"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="12"/>
<inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
<state key="normal" title="Load">
<color key="titleColor" red="0.016804177310000001" green="0.19835099580000001" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</state>
<state key="disabled" title="Load">
<color key="titleColor" white="0.33333333329999998" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</state>
<connections>
<action selector="loadRewardedAdButtonTapped:" destination="BYZ-38-t0r" eventType="touchUpInside" id="QsF-UR-cXP"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" enabled="NO" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" showsTouchWhenHighlighted="YES" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="XVv-PB-vQc" userLabel="Show Interstitial Button">
<rect key="frame" x="120" y="0.0" width="100" height="30"/>
<constraints>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="220" id="lAN-1u-Ze6"/>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="100" id="y3W-vB-9Cn"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="12"/>
<inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
<state key="normal" title="Show">
<color key="titleColor" red="0.016804177310000001" green="0.19835099580000001" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</state>
<state key="disabled" title="Initializing">
<state key="disabled" title="Show">
<color key="titleColor" white="0.33333333329999998" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</state>
<state key="selected" title="Show"/>
<state key="highlighted" title="Show"/>
<connections>
<action selector="showRewardedVideoButtonTapped:" destination="BYZ-38-t0r" eventType="touchUpInside" id="guv-d3-Lxh"/>
<action selector="showRewardedAdButtonTapped:" destination="BYZ-38-t0r" eventType="touchUpInside" id="cSS-Qo-2RF"/>
</connections>
</button>
</subviews>
<constraints>
<constraint firstAttribute="height" constant="30" id="smx-X3-aLJ"/>
<constraint firstAttribute="height" constant="30" id="cI9-GT-fOR"/>
</constraints>
</stackView>
</subviews>
Expand Down Expand Up @@ -147,7 +164,7 @@
<color key="titleColor" white="0.33333333329999998" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</state>
<connections>
<action selector="loadBannerButtonTapped:" destination="BYZ-38-t0r" eventType="touchUpInside" id="JxN-za-vS6"/>
<action selector="loadBannerAdButtonTapped:" destination="BYZ-38-t0r" eventType="touchUpInside" id="JxN-za-vS6"/>
</connections>
</button>
</subviews>
Expand All @@ -174,10 +191,11 @@
</constraints>
</view>
<connections>
<outlet property="loadBannerButton" destination="DN1-DN-sO8" id="rHw-dA-GPy"/>
<outlet property="loadInterstitialButton" destination="qE4-Rn-VtA" id="5Wh-Ea-XS0"/>
<outlet property="showInterstitialButton" destination="Dhm-wI-nt6" id="lZv-jU-P6G"/>
<outlet property="showRewardedVideoButton" destination="N20-QP-8mE" id="TcG-9c-34W"/>
<outlet property="loadBannerAdButton" destination="DN1-DN-sO8" id="rHw-dA-GPy"/>
<outlet property="loadInterstitialAdButton" destination="qE4-Rn-VtA" id="5Wh-Ea-XS0"/>
<outlet property="loadRewardedAdButton" destination="AkV-kT-JiG" id="Xv1-Bi-xIb"/>
<outlet property="showInterstitialAdButton" destination="Dhm-wI-nt6" id="lZv-jU-P6G"/>
<outlet property="showRewardedAdButton" destination="XVv-PB-vQc" id="yqM-TZ-TFh"/>
<outlet property="versionLabel" destination="Dnw-Fv-bW3" id="eDm-X0-027"/>
<outlet property="view" destination="8bC-Xf-vdC" id="QcE-Fc-CwI"/>
</connections>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class DemoBannerAdDelegate: NSObject, LPMBannerAdViewDelegate {
*/
func didLoadAd(with adInfo: LPMAdInfo) {
logCallbackName(string: "\(#function) adInfo = \(String(describing:adInfo.self))")
self.delegate?.setButtonEnablement(ButtonIdentifiers.loadBannerButtonIdentifier, enable: false)
self.delegate?.setButtonEnablement(ButtonIdentifiers.loadBannerAdButtonIdentifier, enable: false)
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class DemoInterstitialAdDelegate: NSObject, LPMInterstitialAdDelegate {
*/
func didLoadAd(with adInfo: LPMAdInfo) {
logCallbackName(string: "\(#function) adInfo = \(String(describing:adInfo.self))")
self.delegate?.setButtonEnablement(ButtonIdentifiers.showInterstitialButtonIdentifier, enable: true)
self.delegate?.setButtonEnablement(ButtonIdentifiers.showInterstitialAdButtonIdentifier, enable: true)
}

/**
Expand All @@ -31,7 +31,7 @@ class DemoInterstitialAdDelegate: NSObject, LPMInterstitialAdDelegate {
*/
func didFailToLoadAd(withAdUnitId adUnitId: String, error: Error) {
logCallbackName(string: "\(#function) error = \(String(describing:error.self))")
self.delegate?.setButtonEnablement(ButtonIdentifiers.showInterstitialButtonIdentifier, enable: false)
self.delegate?.setButtonEnablement(ButtonIdentifiers.showInterstitialAdButtonIdentifier, enable: false)
}

/**
Expand All @@ -50,7 +50,7 @@ class DemoInterstitialAdDelegate: NSObject, LPMInterstitialAdDelegate {
*/
func didDisplayAd(with adInfo: LPMAdInfo) {
logCallbackName(string: "\(#function) adInfo = \(String(describing:adInfo.self))")
self.delegate?.setButtonEnablement(ButtonIdentifiers.showInterstitialButtonIdentifier, enable: false)
self.delegate?.setButtonEnablement(ButtonIdentifiers.showInterstitialAdButtonIdentifier, enable: false)
}

/**
Expand Down
67 changes: 37 additions & 30 deletions iOS/Swift/IronSourceSwiftDemoApp/DemoRewardedVideoAdDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,79 +8,86 @@
import Foundation
import IronSource

class DemoRewardedVideoAdDelegate: NSObject, LevelPlayRewardedVideoDelegate {
class DemoRewardedVideoAdDelegate: NSObject, LPMRewardedAdDelegate {

weak var delegate: DemoViewControllerDelegate?

init(delegate: DemoViewControllerDelegate!) {
self.delegate = delegate
}

/**
Called after a rewarded video has changed its availability to true.
Called after a rewarded ad has been loaded
@param adInfo The info of the ad.
*/
func hasAvailableAd(with adInfo: ISAdInfo!) {
func didLoadAd(with adInfo: LPMAdInfo) {
logCallbackName(string: "\(#function) adInfo = \(String(describing:adInfo.self))")
self.delegate?.setButtonEnablement(ButtonIdentifiers.showRewardedVideoButtonIdentifier, enable: true)
self.delegate?.setButtonEnablement(ButtonIdentifiers.showRewardedAdButtonIdentifier, enable: true)
}

/**
Called after a rewarded video has changed its availability to false.
Called after a rewarded ad has attempted to load but failed.
@param error The reason for the error
*/
func hasNoAvailableAd() {
logCallbackName()
self.delegate?.setButtonEnablement(ButtonIdentifiers.showRewardedVideoButtonIdentifier, enable: false)
func didFailToLoadAd(withAdUnitId adUnitId: String, error: Error) {
logCallbackName(string: "\(#function) error = \(String(describing:error.self))")
self.delegate?.setButtonEnablement(ButtonIdentifiers.showRewardedAdButtonIdentifier, enable: false)
}

/**
Called after the ad info is updated. Available when another rewarded ad has loaded, and includes a higher CPM/Rate
@param adInfo The info of the ad
*/
func didChangeAdInfo(_ adInfo: LPMAdInfo) {
logCallbackName(string: "\(#function) adInfo = \(String(describing:adInfo.self))")
}

/**
Called after a rewarded video has been opened.
Called after a rewarded ad has been opened.
This is the indication for impression.
@param adInfo The info of the ad.
*/
func didOpen(with adInfo: ISAdInfo!) {
func didDisplayAd(with adInfo: LPMAdInfo) {
logCallbackName(string: "\(#function) adInfo = \(String(describing:adInfo.self))")
self.delegate?.setButtonEnablement(ButtonIdentifiers.showRewardedVideoButtonIdentifier, enable: true)
self.delegate?.setButtonEnablement(ButtonIdentifiers.showRewardedAdButtonIdentifier, enable: false)
}

/**
Called after a rewarded video has attempted to show but failed.
Called after a rewarded ad has attempted to show but failed.
@param error The reason for the error.
@param adInfo The info of the ad.
*/
func didFailToShowWithError(_ error: Error!, andAdInfo adInfo: ISAdInfo!) {
func didFailToDisplayAd(with adInfo: LPMAdInfo, error: Error) {
logCallbackName(string: "\(#function) error = \(String(describing:error.self)) | adInfo = \(String(describing:adInfo.self))")
}

/**
Called after a rewarded video has been clicked.
This callback is not supported by all networks, and we recommend using it
only if it's supported by all networks you included in your build
@param placementInfo An object that contains the placement's reward name and amount.
Called after a rewarded ad has been viewed completely and the user is eligible for a reward.
@param reward An object that contains the reward name and amount.
@param adInfo The info of the ad.
*/
func didClick(_ placementInfo: ISPlacementInfo!, with adInfo: ISAdInfo!) {
logCallbackName(string: "\(#function) placement = \(String(describing:placementInfo.self)) | adInfo = \(String(describing:adInfo.self))")
*/
func didRewardAd(with adInfo: LPMAdInfo, reward: LPMReward) {
logCallbackName(string: "\(#function) reward = \(String(describing:reward.self)) | adInfo = \(String(describing:adInfo.self))")
self.delegate?.setRewardInfo(reward)
}

/**
Called after a rewarded video has been viewed completely and the user is eligible for a reward.
@param placementInfo An object that contains the placement's reward name and amount.
Called after a rewarded ad has been clicked.
@param adInfo The info of the ad.
*/
func didReceiveReward(forPlacement placementInfo: ISPlacementInfo!, with adInfo: ISAdInfo!) {
logCallbackName(string: "\(#function) placement = \(String(describing:placementInfo.self)) | adInfo = \(String(describing:adInfo.self))")
self.delegate?.setPlacementInfo(placementInfo)
func didClickAd(with adInfo: LPMAdInfo) {
logCallbackName(string: "\(#function) adInfo = \(String(describing:adInfo.self))")
}

/**
Called after a rewarded video has been dismissed.
Called after a rewarded ad has been dismissed.
@param adInfo The info of the ad.
*/
func didClose(with adInfo: ISAdInfo!) {
func didCloseAd(with adInfo: LPMAdInfo) {
logCallbackName(string: "\(#function) adInfo = \(String(describing:adInfo.self))")
self.delegate?.showVideoRewardMessage()
}

//MARK: Helper Method

func logCallbackName(string: String = #function) {
Expand Down
Loading