Skip to content
Merged
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
6 changes: 4 additions & 2 deletions GADManager/GADManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -362,15 +362,17 @@ public class GADManager<E : RawRepresentable> : NSObject, GoogleMobileAds.FullSc
}

func reprepare(adObject: NSObject, isTesting: Bool = false){
guard let name = self.name(forAdObject: adObject), let unit = E.init(rawValue: name), let interval = self.intervals[unit] else{
guard let name = self.name(forAdObject: adObject), let unit = E.init(rawValue: name) else{
return;
}

let isTesting = self.isTesting[unit] ?? isTesting;

if adObject is GoogleMobileAds.InterstitialAd{
guard self.intervals[unit] != nil else { return }
self.reprepare(interstitialUnit: unit, isTesting: isTesting);
Comment on lines +372 to 373

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 These `guard` statements are redundant and can be simplified.

Since the if/else if blocks already distinguish between ad types, and the reprepare methods for Interstitial and AppOpen ads are capable of handling nil intervals (by using defaults), these guards don't add functional value. Additionally, returning from the entire function here might be unexpected if more logic were to be added at the end of this method. This applies to both the Interstitial and AppOpen ad branches.

Suggested change
guard self.intervals[unit] != nil else { return }
self.reprepare(interstitialUnit: unit, isTesting: isTesting);
self.reprepare(interstitialUnit: unit, isTesting: isTesting);

}else if adObject is GoogleMobileAds.AppOpenAd{
guard self.intervals[unit] != nil else { return }
self.reprepare(openingUnit: unit, isTesting: isTesting);
}else if adObject is GoogleMobileAds.RewardedAd{
self.reprepare(rewardUnit: unit, isTesting: isTesting);
Expand Down
Loading