Can't Close GADRewardedAd

153 views
Skip to first unread message

Ahmad

unread,
Aug 9, 2023, 4:53:39 AM8/9/23
to Google Mobile Ads SDK Developers
I try to hit the button multiple times but it won't disappear.

Google-Mobile-Ads-SDK (10.9.0)


import GoogleMobileAds


class MenuViewController: UIViewController,GADFullScreenContentDelegate {    

    private var rewardedAd: GADRewardedAd?

    func loadRewardedAd() {

      let request = GADRequest()

      GADRewardedAd.load(withAdUnitID:"ca-app-pub-3940256099942544/1712485313",

                       request: request,

                       completionHandler: { [self] ad, error in

        if let error = error {

          print("Failed to load rewarded ad with error: \(error.localizedDescription)")

          return

        }

        rewardedAd = ad

        print("Rewarded ad loaded.")

        rewardedAd?.fullScreenContentDelegate = self

      }

      )

    }


    /// Tells the delegate that the ad failed to present full screen content.

    func ad(_ ad: GADFullScreenPresentingAd, didFailToPresentFullScreenContentWithError error: Error) {

      print("Ad did fail to present full screen content.")

    }


    /// Tells the delegate that the ad will present full screen content.

    func adWillPresentFullScreenContent(_ ad: GADFullScreenPresentingAd) {

      print("Ad will present full screen content.")

    }


    /// Tells the delegate that the ad dismissed full screen content.

    func adDidDismissFullScreenContent(_ ad: GADFullScreenPresentingAd) {

      print("Ad did dismiss full screen content.")

    }


override func viewDidLoad() {


        super.viewDidLoad()

        loadRewardedAd()

}


// I run it with this code

if let ad = rewardedAd {

            ad.present(fromRootViewController: self) {

              let reward = ad.adReward

              print("Reward received with currency \(reward.amount), amount \(reward.amount.doubleValue)")

              // TODO: Reward the user.

            }

          } else {

            print("Ad wasn't ready")

          }



I get the message "Ad will present full screen content." and the callback is also runing and shows the message "Reward received with currency 10, amount 10.0"

Any idea how to fix this?!


RPReplay_Final1691570789.mov

Mobile Ads SDK Forum Advisor

unread,
Aug 9, 2023, 8:28:06 AM8/9/23
to aproje...@gmail.com, google-adm...@googlegroups.com
Hello,

Welcome to Mobile Ads SDK Support team. Thank you for reaching out to us.

I have tested on my end and it appears that I wasn't able to replicate the same behavior. Having said that, for us to be able to further investigation on this issue, kindly provide the below information.
  • sample project implementation (if possible)
  • affected device details (name and version) - kindly also confirm if on real device or simulator


If the file(s) you are looking to share are less than 25mb in total you can attach them to this case on your next reply. If you are having trouble attaching your file to this case or if your file(s) are larger than 25mb, you can share your files with me by performing the following steps:

1. Navigate to

https://docs.google.com/forms/d/e/1FAIpQLSfkAiXMeYP-fw1W3Z-tT9uwmATEKO5X6S-th0gR2ezdKaaqfg/viewform?usp=pp_url&entry.400550049=Mobile+Ads+SDK&entry.460850823=5004Q00002nq7CzQAI&entry.80707362=00192426

2. Fill out all fields, and attach your file(s).

3. Please reply back on this thread when you have uploaded your file(s). Please do not share this link.

 
This message is in relation to case "ref:_00D1U1174p._5004Q2nq7Cz:ref"

Thanks,
 
Google Logo Mobile Ads SDK Team


Ahmad

unread,
Aug 10, 2023, 2:18:20 AM8/10/23
to Google Mobile Ads SDK Developers


I tried to create a sample project but I faced issues with pod install (below is the error message). 

Then I run the command "sudo gem update xcodeproj" then the pod issue got fixed and the main issue with closing the GADRewardedAd got fixed also. 

My Main project is working now, and the GADRewardedAd is closing once I tap the X button without changing anything in my code.

I think it was a cocoapods issue with my device (Apple M1 Pro, MacOS Ventura 13.2.1).

Before I was testing on my device iPhone 11 pro running iOS 16.6 and for the reference before the issue is fixed I used a workaround to close the Ad by adding "self.dismiss(animated: true)" inside the "present(fromRootViewController: self)" callback.

Thanks for your assistance.


% arch -x86_64 pod install /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/universal-darwin22/rbconfig.rb:21: warning: Insecure world writable dir /Users/projects in PATH, mode 040777 Ignoring ffi-1.15.5 because its extensions are not built. Try: gem pristine ffi --version 1.15.5 Analyzing dependencies /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.3/lib/cocoapods/user_interface/error_report.rb:34:in `force_encoding': can't modify frozen String (FrozenError) from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.3/lib/cocoapods/user_interface/error_report.rb:34:in `report' from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.3/lib/cocoapods/command.rb:66:in `report_error' from /Library/Ruby/Gems/2.6.0/gems/claide-1.1.0/lib/claide/command.rb:396:in `handle_exception' from /Library/Ruby/Gems/2.6.0/gems/claide-1.1.0/lib/claide/command.rb:337:in `rescue in run' from /Library/Ruby/Gems/2.6.0/gems/claide-1.1.0/lib/claide/command.rb:324:in `run' from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.3/lib/cocoapods/command.rb:52:in `run' from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.3/bin/pod:55:in `<top (required)>' from /usr/local/bin/pod:23:in `load' from /usr/local/bin/pod:23:in `<main>' /Library/Ruby/Gems/2.6.0/gems/xcodeproj-1.21.0/lib/xcodeproj/project.rb:228:in `initialize_from_file': [Xcodeproj] Unknown object version (56). (RuntimeError) from /Library/Ruby/Gems/2.6.0/gems/xcodeproj-1.21.0/lib/xcodeproj/project.rb:113:in `open' from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.3/lib/cocoapods/installer/analyzer.rb:1190:in `block (2 levels) in inspect_targets_to_integrate' from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.3/lib/cocoapods/installer/analyzer.rb:1189:in `each' from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.3/lib/cocoapods/installer/analyzer.rb:1189:in `block in inspect_targets_to_integrate' from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.3/lib/cocoapods/user_interface.rb:64:in `section' from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.3/lib/cocoapods/installer/analyzer.rb:1184:in `inspect_targets_to_integrate' from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.3/lib/cocoapods/installer/analyzer.rb:106:in `analyze' from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.3/lib/cocoapods/installer.rb:416:in `analyze' from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.3/lib/cocoapods/installer.rb:241:in `block in resolve_dependencies' from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.3/lib/cocoapods/user_interface.rb:64:in `section' from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.3/lib/cocoapods/installer.rb:240:in `resolve_dependencies' from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.3/lib/cocoapods/installer.rb:161:in `install!' from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.3/lib/cocoapods/command/install.rb:52:in `run' from /Library/Ruby/Gems/2.6.0/gems/claide-1.1.0/lib/claide/command.rb:334:in `run' from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.3/lib/cocoapods/command.rb:52:in `run' from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.3/bin/pod:55:in `<top (required)>' from /usr/local/bin/pod:23:in `load' from /usr/local/bin/pod:23:in `<main>'

Mobile Ads SDK Forum Advisor

unread,
Aug 10, 2023, 6:23:07 AM8/10/23
to aproje...@gmail.com, google-adm...@googlegroups.com
Hello,

Thank you for responding back to us. The information shared may be helpful to us since we are tracking the issue of closing the rewarded ads reported also by the other user. You may check this dashboard as well https://ads.google.com/status/publisher/incidents/Ggsm2CBQqW24wXzTkUbJ. However, in your case, it appears that your issue on rewarded ads has been resolved altogether with the cocoapods. On that sense, please do not hesitate to come back to us should you encounter other Admob issue in the future and we will be happy to assist you.
Reply all
Reply to author
Forward
0 new messages