Skip to content

Commit

Permalink
Format fix
Browse files Browse the repository at this point in the history
  • Loading branch information
LTPhantom committed Aug 9, 2024
1 parent 4966287 commit d05e62c
Show file tree
Hide file tree
Showing 28 changed files with 934 additions and 1,263 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#import <GoogleMobileAds/GoogleMobileAds.h>
#import "FLTAd_Internal.h"
#import "FLTGoogleMobileAdsCollection_Internal.h"
#import "FLTGoogleMobileAdsReaderWriter_Internal.h"
#import <GoogleMobileAds/GoogleMobileAds.h>

@protocol FLTAd;
@class FLTBannerAd;
Expand All @@ -33,9 +33,8 @@
- (void)loadAd:(id<FLTAd> _Nonnull)ad;
- (void)dispose:(NSNumber *_Nonnull)adId;
- (void)showAdWithID:(NSNumber *_Nonnull)adId
rootViewController:(UIViewController *_Nonnull)rootViewController;
- (void)onAdLoaded:(id<FLTAd> _Nonnull)ad
responseInfo:(GADResponseInfo *_Nonnull)responseInfo;
rootViewController:(UIViewController *_Nonnull)rootViewController;
- (void)onAdLoaded:(id<FLTAd> _Nonnull)ad responseInfo:(GADResponseInfo *_Nonnull)responseInfo;
- (void)onAdFailedToLoad:(id<FLTAd> _Nonnull)ad error:(NSError *_Nonnull)error;
- (void)onAppEvent:(id<FLTAd> _Nonnull)ad
name:(NSString *_Nullable)name
Expand All @@ -46,10 +45,8 @@
- (void)onNativeAdWillDismissScreen:(FLTNativeAd *_Nonnull)ad;
- (void)onRewardedAdUserEarnedReward:(FLTRewardedAd *_Nonnull)ad
reward:(FLTRewardItem *_Nonnull)reward;
- (void)onRewardedInterstitialAdUserEarnedReward:
(FLTRewardedInterstitialAd *_Nonnull)ad
reward:
(FLTRewardItem *_Nonnull)reward;
- (void)onRewardedInterstitialAdUserEarnedReward:(FLTRewardedInterstitialAd *_Nonnull)ad
reward:(FLTRewardItem *_Nonnull)reward;
- (void)onPaidEvent:(id<FLTAd> _Nonnull)ad value:(FLTAdValue *_Nonnull)value;
- (void)onBannerImpression:(FLTBannerAd *_Nonnull)ad;
- (void)onBannerWillDismissScreen:(FLTBannerAd *_Nonnull)ad;
Expand All @@ -67,9 +64,7 @@
- (void)disposeAllAds;
@end

@interface FLTNewGoogleMobileAdsViewFactory
: NSObject <FlutterPlatformViewFactory>
@interface FLTNewGoogleMobileAdsViewFactory : NSObject <FlutterPlatformViewFactory>
@property(readonly) FLTAdInstanceManager *_Nonnull manager;
- (instancetype _Nonnull)initWithManager:
(FLTAdInstanceManager *_Nonnull)manager;
- (instancetype _Nonnull)initWithManager:(FLTAdInstanceManager *_Nonnull)manager;
@end
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@ - (instancetype _Nonnull)initWithBinaryMessenger:
_ads = [[FLTGoogleMobileAdsCollection alloc] init];
NSObject<FlutterMethodCodec> *methodCodec = [FlutterStandardMethodCodec
codecWithReaderWriter:[[FLTGoogleMobileAdsReaderWriter alloc] init]];
_channel = [[FlutterMethodChannel alloc]
initWithName:@"plugins.flutter.io/google_mobile_ads"
binaryMessenger:binaryMessenger
codec:methodCodec];
_channel = [[FlutterMethodChannel alloc] initWithName:@"plugins.flutter.io/google_mobile_ads"
binaryMessenger:binaryMessenger
codec:methodCodec];
}
return self;
}
Expand Down Expand Up @@ -68,7 +67,7 @@ - (void)disposeAllAds {
}

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

if (!ad) {
Expand All @@ -79,14 +78,12 @@ - (void)showAdWithID:(NSNumber *_Nonnull)adId
[ad showFromRootViewController:rootViewController];
}

- (void)onAdLoaded:(id<FLTAd> _Nonnull)ad
responseInfo:(GADResponseInfo *_Nonnull)responseInfo {
- (void)onAdLoaded:(id<FLTAd> _Nonnull)ad responseInfo:(GADResponseInfo *_Nonnull)responseInfo {
[_channel invokeMethod:@"onAdEvent"
arguments:@{
@"adId" : ad.adId,
@"eventName" : @"onAdLoaded",
@"responseInfo" : [[FLTGADResponseInfo alloc]
initWithResponseInfo:responseInfo]
@"responseInfo" : [[FLTGADResponseInfo alloc] initWithResponseInfo:responseInfo]
}];
}

Expand All @@ -99,9 +96,7 @@ - (void)onAdFailedToLoad:(id<FLTAd> _Nonnull)ad error:(NSError *_Nonnull)error {
}];
}

- (void)onAppEvent:(id<FLTAd> _Nonnull)ad
name:(NSString *)name
data:(NSString *)data {
- (void)onAppEvent:(id<FLTAd> _Nonnull)ad name:(NSString *)name data:(NSString *)data {
[_channel invokeMethod:@"onAdEvent"
arguments:@{
@"adId" : ad.adId,
Expand Down Expand Up @@ -137,10 +132,8 @@ - (void)onRewardedAdUserEarnedReward:(FLTRewardedAd *_Nonnull)ad
}];
}

- (void)onRewardedInterstitialAdUserEarnedReward:
(FLTRewardedInterstitialAd *_Nonnull)ad
reward:
(FLTRewardItem *_Nonnull)reward {
- (void)onRewardedInterstitialAdUserEarnedReward:(FLTRewardedInterstitialAd *_Nonnull)ad
reward:(FLTRewardItem *_Nonnull)reward {
[_channel invokeMethod:@"onAdEvent"
arguments:@{
@"adId" : ad.adId,
Expand Down Expand Up @@ -239,17 +232,12 @@ - (instancetype)initWithManager:(FLTAdInstanceManager *_Nonnull)manager {
viewIdentifier:(int64_t)viewId
arguments:(id _Nullable)args {
NSNumber *adId = args;
NSObject<FlutterPlatformView> *view =
(NSObject<FlutterPlatformView> *)[_manager adFor:adId];
NSObject<FlutterPlatformView> *view = (NSObject<FlutterPlatformView> *)[_manager adFor:adId];

if (!view) {
NSString *reason = [NSString
stringWithFormat:
@"Could not find an ad with id: %@. Was this ad already disposed?",
adId];
@throw [NSException exceptionWithName:NSInvalidArgumentException
reason:reason
userInfo:nil];
stringWithFormat:@"Could not find an ad with id: %@. Was this ad already disposed?", adId];
@throw [NSException exceptionWithName:NSInvalidArgumentException reason:reason userInfo:nil];
}
return view;
}
Expand Down
3 changes: 1 addition & 2 deletions packages/google_mobile_ads/ios/Classes/FLTAdUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
+ (BOOL)isNotNull:(_Nullable id)object;

+ (WKWebView *_Nullable)getWebView:(NSNumber *_Nonnull)webViewId
flutterPluginRegistry:
(id<FlutterPluginRegistry> _Nonnull)flutterPluginRegistry;
flutterPluginRegistry:(id<FlutterPluginRegistry> _Nonnull)flutterPluginRegistry;

@property(readonly, class) NSString *_Nonnull requestAgent;

Expand Down
18 changes: 8 additions & 10 deletions packages/google_mobile_ads/ios/Classes/FLTAdUtil.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,20 @@ + (BOOL)isNotNull:(id)object {

+ (NSString *)requestAgent {
NSString *newsTemplateString = @"";
id newsTemplateVersion = [NSBundle.mainBundle
objectForInfoDictionaryKey:@"FLTNewsTemplateVersion"];
id newsTemplateVersion =
[NSBundle.mainBundle objectForInfoDictionaryKey:@"FLTNewsTemplateVersion"];
if ([newsTemplateVersion isKindOfClass:[NSString class]]) {
newsTemplateString =
[NSString stringWithFormat:@"_News-%@", newsTemplateVersion];
newsTemplateString = [NSString stringWithFormat:@"_News-%@", newsTemplateVersion];
}

NSString *gameTemplateString = @"";
id gameTemplateVersion = [NSBundle.mainBundle
objectForInfoDictionaryKey:@"FLTGameTemplateVersion"];
id gameTemplateVersion =
[NSBundle.mainBundle objectForInfoDictionaryKey:@"FLTGameTemplateVersion"];
if ([gameTemplateVersion isKindOfClass:[NSString class]]) {
gameTemplateString =
[NSString stringWithFormat:@"_Game-%@", gameTemplateVersion];
gameTemplateString = [NSString stringWithFormat:@"_Game-%@", gameTemplateVersion];
}
return [NSString stringWithFormat:@"%@%@%@", FLT_REQUEST_AGENT_VERSIONED,
newsTemplateString, gameTemplateString];
return [NSString stringWithFormat:@"%@%@%@", FLT_REQUEST_AGENT_VERSIONED, newsTemplateString,
gameTemplateString];
}

+ (WKWebView *)getWebView:(NSNumber *)webViewId
Expand Down
108 changes: 42 additions & 66 deletions packages/google_mobile_ads/ios/Classes/FLTAd_Internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#import <GoogleMobileAds/GoogleMobileAds.h>
#import <UIKit/UIKit.h>
#import "FLTAdInstanceManager_Internal.h"
#import "FLTGoogleMobileAdsPlugin.h"
#import "FLTMediationExtras.h"
#import "FLTMediationNetworkExtrasProvider.h"
#import "FLTMobileAds_Internal.h"
#import "FLTNativeTemplateStyle.h"
#import "GADTTemplateView.h"
#import <GoogleMobileAds/GoogleMobileAds.h>
#import <UIKit/UIKit.h>

@class FLTAdInstanceManager;
@protocol FLTNativeAdFactory;
Expand All @@ -29,8 +29,7 @@
@property(readonly) GADAdSize size;
@property(readonly) NSNumber *_Nonnull width;
@property(readonly) NSNumber *_Nonnull height;
- (instancetype _Nonnull)initWithWidth:(NSNumber *_Nonnull)width
height:(NSNumber *_Nonnull)height;
- (instancetype _Nonnull)initWithWidth:(NSNumber *_Nonnull)width height:(NSNumber *_Nonnull)height;
- (instancetype _Nonnull)initWithAdSize:(GADAdSize)size;
@end

Expand All @@ -39,22 +38,14 @@
* Plugin.
*/
@interface FLTAdSizeFactory : NSObject
- (GADAdSize)portraitAnchoredAdaptiveBannerAdSizeWithWidth:
(NSNumber *_Nonnull)width;
- (GADAdSize)landscapeAnchoredAdaptiveBannerAdSizeWithWidth:
(NSNumber *_Nonnull)width;
- (GADAdSize)currentOrientationAnchoredAdaptiveBannerAdSizeWithWidth:
(NSNumber *_Nonnull)width;
- (GADAdSize)currentOrientationInlineAdaptiveBannerSizeWithWidth:
(NSNumber *_Nonnull)width;
- (GADAdSize)portraitOrientationInlineAdaptiveBannerSizeWithWidth:
(NSNumber *_Nonnull)width;
- (GADAdSize)landscapeInlineAdaptiveBannerAdSizeWithWidth:
(NSNumber *_Nonnull)width;
- (GADAdSize)
inlineAdaptiveBannerAdSizeWithWidthAndMaxHeight:(NSNumber *_Nonnull)width
maxHeight:
(NSNumber *_Nonnull)maxHeight;
- (GADAdSize)portraitAnchoredAdaptiveBannerAdSizeWithWidth:(NSNumber *_Nonnull)width;
- (GADAdSize)landscapeAnchoredAdaptiveBannerAdSizeWithWidth:(NSNumber *_Nonnull)width;
- (GADAdSize)currentOrientationAnchoredAdaptiveBannerAdSizeWithWidth:(NSNumber *_Nonnull)width;
- (GADAdSize)currentOrientationInlineAdaptiveBannerSizeWithWidth:(NSNumber *_Nonnull)width;
- (GADAdSize)portraitOrientationInlineAdaptiveBannerSizeWithWidth:(NSNumber *_Nonnull)width;
- (GADAdSize)landscapeInlineAdaptiveBannerAdSizeWithWidth:(NSNumber *_Nonnull)width;
- (GADAdSize)inlineAdaptiveBannerAdSizeWithWidthAndMaxHeight:(NSNumber *_Nonnull)width
maxHeight:(NSNumber *_Nonnull)maxHeight;

@end

Expand Down Expand Up @@ -87,10 +78,9 @@
@property NSString *_Nullable contentURL;
@property BOOL nonPersonalizedAds;
@property NSArray<NSString *> *_Nullable neighboringContentURLs;
@property NSString *_Nullable mediationExtrasIdentifier
DEPRECATED_MSG_ATTRIBUTE("Use mediationExtras instead.");
@property id<
FLTMediationNetworkExtrasProvider> _Nullable mediationNetworkExtrasProvider
@property NSString *_Nullable mediationExtrasIdentifier DEPRECATED_MSG_ATTRIBUTE(
"Use mediationExtras instead.");
@property id<FLTMediationNetworkExtrasProvider> _Nullable mediationNetworkExtrasProvider
DEPRECATED_MSG_ATTRIBUTE("Use mediationExtras instead.");
@property NSDictionary<NSString *, NSString *> *_Nullable adMobExtras;
@property NSString *_Nonnull requestAgent;
Expand All @@ -114,8 +104,7 @@
@property NSString *_Nullable adSourceName;
@property NSString *_Nullable adSourceInstanceName;

- (instancetype _Nonnull)initWithResponseInfo:
(GADAdNetworkResponseInfo *_Nonnull)responseInfo;
- (instancetype _Nonnull)initWithResponseInfo:(GADAdNetworkResponseInfo *_Nonnull)responseInfo;
@end

/**
Expand All @@ -128,8 +117,7 @@
@property FLTGADAdNetworkResponseInfo *_Nullable loadedAdNetworkResponseInfo;
@property NSDictionary<NSString *, id> *_Nullable extrasDictionary;

- (instancetype _Nonnull)initWithResponseInfo:
(GADResponseInfo *_Nonnull)responseInfo;
- (instancetype _Nonnull)initWithResponseInfo:(GADResponseInfo *_Nonnull)responseInfo;
@end

/**
Expand All @@ -150,8 +138,7 @@
*/
@interface FLTGAMAdRequest : FLTAdRequest
@property NSDictionary<NSString *, NSString *> *_Nullable customTargeting;
@property NSDictionary<NSString *, NSArray<NSString *> *>
*_Nullable customTargetingLists;
@property NSDictionary<NSString *, NSArray<NSString *> *> *_Nullable customTargetingLists;
@property NSString *_Nullable pubProvidedID;

- (GAMRequest *_Nonnull)asGAMRequest:(NSString *_Nonnull)adUnitId;
Expand All @@ -171,13 +158,11 @@
@property(readonly) NSNumber *_Nonnull adId;
@end

@interface FLTBannerAd
: FLTBaseAd <FLTAd, FlutterPlatformView, GADBannerViewDelegate>
@interface FLTBannerAd : FLTBaseAd <FLTAd, FlutterPlatformView, GADBannerViewDelegate>
- (instancetype _Nonnull)initWithAdUnitId:(NSString *_Nonnull)adUnitId
size:(FLTAdSize *_Nonnull)size
request:(FLTAdRequest *_Nonnull)request
rootViewController:
(UIViewController *_Nonnull)rootViewController
rootViewController:(UIViewController *_Nonnull)rootViewController
adId:(NSNumber *_Nonnull)adId;
- (FLTAdSize *_Nullable)getAdSize;
- (GADBannerView *_Nonnull)bannerView;
Expand All @@ -190,8 +175,7 @@
- (instancetype _Nonnull)initWithAdUnitId:(NSString *_Nonnull)adUnitId
sizes:(NSArray<FLTAdSize *> *_Nonnull)sizes
request:(FLTGAMAdRequest *_Nonnull)request
rootViewController:
(UIViewController *_Nonnull)rootViewController
rootViewController:(UIViewController *_Nonnull)rootViewController
adId:(NSNumber *_Nonnull)adId;

@end
Expand All @@ -202,13 +186,11 @@
@interface FLTFluidGAMBannerAd : FLTGAMBannerAd <GADAdSizeDelegate>
- (instancetype _Nonnull)initWithAdUnitId:(NSString *_Nonnull)adUnitId
request:(FLTGAMAdRequest *_Nonnull)request
rootViewController:
(UIViewController *_Nonnull)rootViewController
rootViewController:(UIViewController *_Nonnull)rootViewController
adId:(NSNumber *_Nonnull)adId;
@end

@interface FLTFullScreenAd
: FLTBaseAd <FLTAd, FLTAdWithoutView, GADFullScreenContentDelegate>
@interface FLTFullScreenAd : FLTBaseAd <FLTAd, FLTAdWithoutView, GADFullScreenContentDelegate>
@end

@interface FLTInterstitialAd : FLTFullScreenAd
Expand Down Expand Up @@ -256,10 +238,9 @@
@property(readonly) NSNumber *_Nullable clickToExpandRequested;
@property(readonly) NSNumber *_Nullable customControlsRequested;
@property(readonly) NSNumber *_Nullable startMuted;
- (instancetype _Nonnull)
initWithClickToExpandRequested:(NSNumber *_Nullable)clickToExpandRequested
customControlsRequested:(NSNumber *_Nullable)customControlsRequested
startMuted:(NSNumber *_Nullable)startMuted;
- (instancetype _Nonnull)initWithClickToExpandRequested:(NSNumber *_Nullable)clickToExpandRequested
customControlsRequested:(NSNumber *_Nullable)customControlsRequested
startMuted:(NSNumber *_Nullable)startMuted;
- (GADVideoOptions *_Nonnull)asGADVideoOptions;

@end
Expand All @@ -272,39 +253,34 @@
@property(readonly) NSNumber *_Nullable shouldRequestMultipleImages;
@property(readonly) NSNumber *_Nullable shouldReturnUrlsForImageAssets;

- (instancetype _Nonnull)
initWithAdChoicesPlacement:(NSNumber *_Nullable)adChoicesPlacement
mediaAspectRatio:(NSNumber *_Nullable)mediaAspectRatio
videoOptions:(FLTVideoOptions *_Nullable)videoOptions
requestCustomMuteThisAd:(NSNumber *_Nullable)requestCustomMuteThisAd
shouldRequestMultipleImages:
(NSNumber *_Nullable)shouldRequestMultipleImages
shouldReturnUrlsForImageAssets:
(NSNumber *_Nullable)shouldReturnUrlsForImageAssets;
- (instancetype _Nonnull)initWithAdChoicesPlacement:(NSNumber *_Nullable)adChoicesPlacement
mediaAspectRatio:(NSNumber *_Nullable)mediaAspectRatio
videoOptions:(FLTVideoOptions *_Nullable)videoOptions
requestCustomMuteThisAd:(NSNumber *_Nullable)requestCustomMuteThisAd
shouldRequestMultipleImages:(NSNumber *_Nullable)shouldRequestMultipleImages
shouldReturnUrlsForImageAssets:
(NSNumber *_Nullable)shouldReturnUrlsForImageAssets;

- (NSArray<GADAdLoaderOptions *> *_Nonnull)asGADAdLoaderOptions;
@end

@interface FLTNativeAd
: FLTBaseAd <FLTAd, FlutterPlatformView, GADNativeAdDelegate,
GADNativeAdLoaderDelegate>
- (instancetype _Nonnull)
initWithAdUnitId:(NSString *_Nonnull)adUnitId
request:(FLTAdRequest *_Nonnull)request
nativeAdFactory:(NSObject<FLTNativeAdFactory> *_Nonnull)nativeAdFactory
customOptions:(NSDictionary<NSString *, id> *_Nullable)customOptions
rootViewController:(UIViewController *_Nonnull)rootViewController
adId:(NSNumber *_Nonnull)adId
nativeAdOptions:(FLTNativeAdOptions *_Nullable)nativeAdOptions
nativeTemplateStyle:(FLTNativeTemplateStyle *_Nullable)nativeTemplateStyle;
: FLTBaseAd <FLTAd, FlutterPlatformView, GADNativeAdDelegate, GADNativeAdLoaderDelegate>
- (instancetype _Nonnull)initWithAdUnitId:(NSString *_Nonnull)adUnitId
request:(FLTAdRequest *_Nonnull)request
nativeAdFactory:(NSObject<FLTNativeAdFactory> *_Nonnull)nativeAdFactory
customOptions:(NSDictionary<NSString *, id> *_Nullable)customOptions
rootViewController:(UIViewController *_Nonnull)rootViewController
adId:(NSNumber *_Nonnull)adId
nativeAdOptions:(FLTNativeAdOptions *_Nullable)nativeAdOptions
nativeTemplateStyle:(FLTNativeTemplateStyle *_Nullable)nativeTemplateStyle;
- (GADAdLoader *_Nonnull)adLoader;
@end

@interface FLTRewardItem : NSObject
@property(readonly) NSNumber *_Nonnull amount;
@property(readonly) NSString *_Nonnull type;
- (instancetype _Nonnull)initWithAmount:(NSNumber *_Nonnull)amount
type:(NSString *_Nonnull)type;
- (instancetype _Nonnull)initWithAmount:(NSNumber *_Nonnull)amount type:(NSString *_Nonnull)type;
@end

@interface FLTAdValue : NSObject
Expand Down
Loading

0 comments on commit d05e62c

Please sign in to comment.