Skip to content

Commit

Permalink
Removed rootViewController reference for fullscreen ads
Browse files Browse the repository at this point in the history
  • Loading branch information
LTPhantom committed Aug 12, 2024
1 parent 1c71d40 commit 15f0430
Show file tree
Hide file tree
Showing 12 changed files with 21 additions and 120 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@
9E61AA6029BBE8FD00801A83 /* FLTNativeTemplateStyleTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 9E61AA5B29BBE8FD00801A83 /* FLTNativeTemplateStyleTest.m */; };
9E61AA6129BBE8FD00801A83 /* FLTNativeTemplateFontStyleTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 9E61AA5C29BBE8FD00801A83 /* FLTNativeTemplateFontStyleTest.m */; };
9E61AA6229BBE8FD00801A83 /* FLTNativeTemplateColorTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 9E61AA5D29BBE8FD00801A83 /* FLTNativeTemplateColorTest.m */; };
C032D0C69E82A86DA475F8FE /* libPods-RunnerTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 72FE6B99C77221F59BD2657E /* libPods-RunnerTests.a */; };
CB51B8C665175A2D77BE7B0B /* libPods-Runner.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 552A358A77902B418501B0E8 /* libPods-Runner.a */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -67,13 +65,8 @@
/* Begin PBXFileReference section */
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
27B7088677C69B9B87E86B96 /* Pods-RunnerTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.debug.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.debug.xcconfig"; sourceTree = "<group>"; };
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
44F3DED22B745BEE004D7117 /* FLTMediationExtras.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = FLTMediationExtras.h; path = ../../ios/Classes/FLTMediationExtras.h; sourceTree = "<group>"; };
5088939374F111D280B15613 /* Pods-RunnerTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.release.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.release.xcconfig"; sourceTree = "<group>"; };
552A358A77902B418501B0E8 /* libPods-Runner.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Runner.a"; sourceTree = BUILT_PRODUCTS_DIR; };
72FE6B99C77221F59BD2657E /* libPods-RunnerTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-RunnerTests.a"; sourceTree = BUILT_PRODUCTS_DIR; };
7382CA922D972355676543EB /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = "<group>"; };
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -157,23 +150,20 @@
9EF4E6FE26392B230007E4FE /* FLTGoogleMobileAdsCollection_Internal.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = FLTGoogleMobileAdsCollection_Internal.m; path = ../../ios/Classes/FLTGoogleMobileAdsCollection_Internal.m; sourceTree = "<group>"; };
9EF4E6FF26392B230007E4FE /* FLTMobileAds_Internal.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = FLTMobileAds_Internal.h; path = ../../ios/Classes/FLTMobileAds_Internal.h; sourceTree = "<group>"; };
9EFEAB4E29B0019F000A063B /* GoogleMobileAds.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = GoogleMobileAds.xcframework; path = "Pods/Google-Mobile-Ads-SDK/Frameworks/GoogleMobileAdsFramework/GoogleMobileAds.xcframework"; sourceTree = "<group>"; };
B01820B337C2EF12599D0744 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
97C146EB1CF9000F007C117D /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
CB51B8C665175A2D77BE7B0B /* libPods-Runner.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
9E61AA1329BBE51900801A83 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
C032D0C69E82A86DA475F8FE /* libPods-RunnerTests.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -183,10 +173,6 @@
194BB02CA5CDABA098EA0B10 /* Pods */ = {
isa = PBXGroup;
children = (
B01820B337C2EF12599D0744 /* Pods-Runner.debug.xcconfig */,
7382CA922D972355676543EB /* Pods-Runner.release.xcconfig */,
27B7088677C69B9B87E86B96 /* Pods-RunnerTests.debug.xcconfig */,
5088939374F111D280B15613 /* Pods-RunnerTests.release.xcconfig */,
);
path = Pods;
sourceTree = "<group>";
Expand All @@ -197,8 +183,6 @@
9EFEAB4E29B0019F000A063B /* GoogleMobileAds.xcframework */,
9EB9FE57280F853D00DDBB4F /* UserMessagingPlatform.xcframework */,
9EA7213525BB6464008D57E3 /* GoogleMobileAds.xcframework */,
552A358A77902B418501B0E8 /* libPods-Runner.a */,
72FE6B99C77221F59BD2657E /* libPods-RunnerTests.a */,
);
name = Frameworks;
sourceTree = "<group>";
Expand Down Expand Up @@ -384,14 +368,12 @@
isa = PBXNativeTarget;
buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */;
buildPhases = (
E92B7B87E1A00D5F29391D09 /* [CP] Check Pods Manifest.lock */,
9740EEB61CF901F6004384FC /* Run Script */,
97C146EA1CF9000F007C117D /* Sources */,
97C146EB1CF9000F007C117D /* Frameworks */,
97C146EC1CF9000F007C117D /* Resources */,
9705A1C41CF9048500538489 /* Embed Frameworks */,
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
88D22564A698FDC5B3114D86 /* [CP] Copy Pods Resources */,
);
buildRules = (
);
Expand All @@ -406,7 +388,6 @@
isa = PBXNativeTarget;
buildConfigurationList = 9E61AA1E29BBE51900801A83 /* Build configuration list for PBXNativeTarget "RunnerTests" */;
buildPhases = (
A1476C20D685A26F4507611D /* [CP] Check Pods Manifest.lock */,
9E61AA1229BBE51900801A83 /* Sources */,
9E61AA1329BBE51900801A83 /* Frameworks */,
9E61AA1429BBE51900801A83 /* Resources */,
Expand Down Expand Up @@ -498,30 +479,6 @@
shellPath = /bin/sh;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed\n/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" thin\n";
};
88D22564A698FDC5B3114D86 /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh",
"${PODS_CONFIGURATION_BUILD_DIR}/Google-Mobile-Ads-SDK/GoogleMobileAdsResources.bundle",
"${PODS_CONFIGURATION_BUILD_DIR}/GoogleUserMessagingPlatform/UserMessagingPlatformResources.bundle",
"${PODS_CONFIGURATION_BUILD_DIR}/google_mobile_ads/google_mobile_ads.bundle",
"${PODS_CONFIGURATION_BUILD_DIR}/webview_flutter_wkwebview/webview_flutter_wkwebview_privacy.bundle",
);
name = "[CP] Copy Pods Resources";
outputPaths = (
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/GoogleMobileAdsResources.bundle",
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/UserMessagingPlatformResources.bundle",
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/google_mobile_ads.bundle",
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/webview_flutter_wkwebview_privacy.bundle",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh\"\n";
showEnvVarsInLog = 0;
};
9740EEB61CF901F6004384FC /* Run Script */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
Expand All @@ -537,50 +494,6 @@
shellPath = /bin/sh;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build\n";
};
A1476C20D685A26F4507611D /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputFileListPaths = (
);
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-RunnerTests-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
E92B7B87E1A00D5F29391D09 /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputFileListPaths = (
);
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
Expand Down Expand Up @@ -819,7 +732,6 @@
};
9E61AA1C29BBE51900801A83 /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 27B7088677C69B9B87E86B96 /* Pods-RunnerTests.debug.xcconfig */;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
Expand All @@ -846,7 +758,6 @@
};
9E61AA1D29BBE51900801A83 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 5088939374F111D280B15613 /* Pods-RunnerTests.release.xcconfig */;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
Expand Down
2 changes: 1 addition & 1 deletion packages/google_mobile_ads/example/ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<key>CFBundleVersion</key>
<string>1</string>
<key>GADApplicationIdentifier</key>
<string>ca-app-pub-3212738706492790~4234003410</string>
<string>ca-app-pub-3940256099942544~1458002511</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>SKAdNetworkItems</key>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ - (void)testLoadShowAppOpenAd:(FLTAdRequest *)request
return TRUE;
}]]);

[ad showFromRootViewController:mockRootViewController];
[ad show];

OCMVerify([appOpenClassMock
presentFromRootViewController:[OCMArg isEqual:mockRootViewController]]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ - (void)testLoadShowInterstitialAd {
}]]);

// Show the ad
[ad showFromRootViewController:mockRootViewController];
[ad show];

OCMVerify([interstitialClassMock
presentFromRootViewController:[OCMArg isEqual:mockRootViewController]]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ - (void)testLoadShowInterstitialAd {
}]]);

// Show the ad
[ad showFromRootViewController:mockRootViewController];
[ad show];

OCMVerify([interstitialClassMock
presentFromRootViewController:[OCMArg isEqual:mockRootViewController]]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ - (void)testLoadShowRewardedAd:(FLTAdRequest *)request
setServerSideVerificationOptions:[OCMArg isEqual:gadOptions]]);

// Show the ad and verify callbacks invoked
[ad showFromRootViewController:mockRootViewController];
[ad show];

OCMVerify([rewardedClassMock
presentFromRootViewController:[OCMArg isEqual:mockRootViewController]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ - (void)testLoadShowRewardedInterstitialAd:(FLTAdRequest *)request
setServerSideVerificationOptions:[OCMArg isEqual:gadOptions]]);

// Show the ad and verify callbacks are invoked
[ad showFromRootViewController:mockRootViewController];
[ad show];

OCMVerify([rewardedInterstitialClassMock
presentFromRootViewController:[OCMArg isEqual:mockRootViewController]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@
- (NSNumber *_Nullable)adIdFor:(id<FLTAd> _Nonnull)ad;
- (void)loadAd:(id<FLTAd> _Nonnull)ad;
- (void)dispose:(NSNumber *_Nonnull)adId;
- (void)showAdWithID:(NSNumber *_Nonnull)adId
rootViewController:(UIViewController *_Nonnull)rootViewController;
- (void)showAdWithID:(NSNumber *_Nonnull)adId;
- (void)onAdLoaded:(id<FLTAd> _Nonnull)ad
responseInfo:(GADResponseInfo *_Nonnull)responseInfo;
- (void)onAdFailedToLoad:(id<FLTAd> _Nonnull)ad error:(NSError *_Nonnull)error;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,15 @@ - (void)disposeAllAds {
[_ads removeAllObjects];
}

- (void)showAdWithID:(NSNumber *_Nonnull)adId
rootViewController:(UIViewController *_Nonnull)rootViewController {
- (void)showAdWithID:(NSNumber *_Nonnull)adId {
id<FLTAdWithoutView> ad = (id<FLTAdWithoutView>)[self adFor:adId];

if (!ad) {
NSLog(@"Can't find ad with id: %@", adId);
return;
}

[ad showFromRootViewController:rootViewController];
[ad show];
}

- (void)onAdLoaded:(id<FLTAd> _Nonnull)ad
Expand Down
3 changes: 1 addition & 2 deletions packages/google_mobile_ads/ios/Classes/FLTAd_Internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,7 @@
@end

@protocol FLTAdWithoutView
- (void)showFromRootViewController:
(UIViewController *_Nonnull)rootViewController;
- (void)show;
@end

@interface FLTBaseAd : NSObject
Expand Down
25 changes: 10 additions & 15 deletions packages/google_mobile_ads/ios/Classes/FLTAd_Internal.m
Original file line number Diff line number Diff line change
Expand Up @@ -726,10 +726,9 @@ - (void)load {
}];
}

- (void)showFromRootViewController:
(UIViewController *_Nonnull)rootViewController {
- (void)show {
if (self.interstitial) {
[self.interstitial presentFromRootViewController:rootViewController];
[self.interstitial presentFromRootViewController:nil];
} else {
NSLog(@"InterstitialAd failed to show because the ad was not ready.");
}
Expand Down Expand Up @@ -790,10 +789,9 @@ - (void)load {
}];
}

- (void)showFromRootViewController:
(UIViewController *_Nonnull)rootViewController {
- (void)show {
if (self.interstitial) {
[self.interstitial presentFromRootViewController:rootViewController];
[self.interstitial presentFromRootViewController:nil];
} else {
NSLog(@"InterstitialAd failed to show because the ad was not ready.");
}
Expand Down Expand Up @@ -871,11 +869,10 @@ - (void)load {
}];
}

- (void)showFromRootViewController:
(UIViewController *_Nonnull)rootViewController {
- (void)show {
if (self.rewardedAd) {
[self.rewardedAd
presentFromRootViewController:rootViewController
presentFromRootViewController:nil
userDidEarnRewardHandler:^{
GADAdReward *reward = self.rewardedAd.adReward;
FLTRewardItem *fltReward =
Expand Down Expand Up @@ -967,11 +964,10 @@ - (void)load {
}];
}

- (void)showFromRootViewController:
(UIViewController *_Nonnull)rootViewController {
- (void)show {
if (self.rewardedInterstitialAd) {
[self.rewardedInterstitialAd
presentFromRootViewController:rootViewController
presentFromRootViewController:nil
userDidEarnRewardHandler:^{
GADAdReward *reward = self.rewardedInterstitialAd.adReward;
FLTRewardItem *fltReward =
Expand Down Expand Up @@ -1063,10 +1059,9 @@ - (void)load {
}];
}

- (void)showFromRootViewController:
(UIViewController *_Nonnull)rootViewController {
- (void)show {
if (self.appOpenAd) {
[self.appOpenAd presentFromRootViewController:rootViewController];
[self.appOpenAd presentFromRootViewController:nil];
} else {
NSLog(@"AppOpenAd failed to show because the ad was not ready.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@ - (UIViewController *)rootController {

- (void)handleMethodCall:(FlutterMethodCall *)call
result:(FlutterResult)result {
NSLog(@"handleMethodCall %@", call.method);
UIViewController *rootController = self.rootController;

if ([call.method isEqualToString:@"MobileAds#initialize"]) {
Expand Down Expand Up @@ -510,8 +509,7 @@ - (void)handleMethodCall:(FlutterMethodCall *)call
[_manager dispose:call.arguments[@"adId"]];
result(nil);
} else if ([call.method isEqualToString:@"showAdWithoutView"]) {
[_manager showAdWithID:call.arguments[@"adId"]
rootViewController:rootController];
[_manager showAdWithID:call.arguments[@"adId"]];
result(nil);
} else if ([call.method
isEqualToString:@"AdSize#getAnchoredAdaptiveBannerAdSize"]) {
Expand Down

0 comments on commit 15f0430

Please sign in to comment.