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

Fix rootViewController problems after SceneDelegate changes #768

Closed
wants to merge 1 commit into from

Conversation

DavidHDJ
Copy link

@DavidHDJ DavidHDJ commented Feb 5, 2023

#767

Description

When you want to use this package with other packages which needs a SceneDelegate you get the error You must set the rootViewController property of <GADInternalBannerView: 0x7fd71ad12be0; frame = (0 0; 320 50); clipsToBounds = YES; autoresize = W+H; backgroundColor = UIExtendedGrayColorSpace 0 0; layer = <CALayer: 0x60000311d600>> before loading a request..

Changing the rootViewController to self fix this problem

Related Issues

#767

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]).
This will ensure a smooth and quick review process. Updating the pubspec.yaml and changelogs is not required.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • My PR includes unit or integration tests for all changed/updated/fixed behaviors (See Contributor Guide).
  • All existing and new tests are passing.
  • I updated/added relevant documentation (doc comments with ///).
  • The analyzer (flutter analyze) does not report any problems on my PR.
  • I read and followed the Flutter Style Guide.
  • I signed the CLA.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Does your PR require plugin users to manually update their apps to accommodate your change?

  • Yes, this is a breaking change (please indicate a breaking change in CHANGELOG.md and increment major revision).
  • No, this is not a breaking change.

@DavidHDJ DavidHDJ changed the title Update FLTAd_Internal.m Fix rootViewController problems after SceneDelegate changes Feb 5, 2023
@@ -355,7 +355,7 @@ - (instancetype)initWithAdUnitId:(NSString *_Nonnull)adUnitId
_bannerView = [[GADBannerView alloc] initWithAdSize:size.size];
_bannerView.adUnitID = adUnitId;
self.adId = adId;
self.bannerView.rootViewController = rootViewController;
self.bannerView.rootViewController = self;
Copy link
Collaborator

Choose a reason for hiding this comment

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

This will break the more general use case, since FLTBannerAd is not a UIViewController. The main issue is that the plugin always uses UIApplication.sharedApplication.delegate.window.rootViewController as the rootViewController for all its ad views.

To fix this issue we'll probably need a new API that lets you override the rootViewController.
Could you update https://github.com/googleads/googleads-mobile-flutter/pull/768/files with a minimally reproducible sample?

@jjliu15
Copy link
Collaborator

jjliu15 commented Apr 17, 2023

Can you check if #818 fixes this issue?

@malandr2 malandr2 closed this Oct 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants