commit | author | age
|
96fe76
|
1 |
// |
L |
2 |
// GADNativeAd.h |
|
3 |
// Google Mobile Ads SDK |
|
4 |
// |
|
5 |
// Copyright 2017 Google LLC. All rights reserved. |
|
6 |
// |
|
7 |
|
|
8 |
#import <Foundation/Foundation.h> |
|
9 |
#import <GoogleMobileAds/GADAdChoicesView.h> |
|
10 |
#import <GoogleMobileAds/GADAdLoaderDelegate.h> |
|
11 |
#import <GoogleMobileAds/GADAdValue.h> |
|
12 |
#import <GoogleMobileAds/GADMediaContent.h> |
|
13 |
#import <GoogleMobileAds/GADMediaView.h> |
|
14 |
#import <GoogleMobileAds/GADMuteThisAdReason.h> |
|
15 |
#import <GoogleMobileAds/GADNativeAdAssetIdentifiers.h> |
|
16 |
#import <GoogleMobileAds/GADNativeAdDelegate.h> |
|
17 |
#import <GoogleMobileAds/GADNativeAdImage.h> |
|
18 |
#import <GoogleMobileAds/GADResponseInfo.h> |
|
19 |
#import <GoogleMobileAds/GADVideoController.h> |
|
20 |
#import <UIKit/UIKit.h> |
|
21 |
|
|
22 |
/// Native ad. To request this ad type, pass GADAdLoaderAdTypeNative |
|
23 |
/// (see GADAdLoaderAdTypes.h) to the |adTypes| parameter in GADAdLoader's initializer method. If |
|
24 |
/// you request this ad type, your delegate must conform to the GADNativeAdLoaderDelegate |
|
25 |
/// protocol. |
|
26 |
@interface GADNativeAd : NSObject |
|
27 |
|
|
28 |
#pragma mark - Must be displayed if available |
|
29 |
|
|
30 |
/// Headline. |
|
31 |
@property(nonatomic, readonly, copy, nullable) NSString *headline; |
|
32 |
|
|
33 |
#pragma mark - Recommended to display |
|
34 |
|
|
35 |
/// Text that encourages user to take some action with the ad. For example "Install". |
|
36 |
@property(nonatomic, readonly, copy, nullable) NSString *callToAction; |
|
37 |
/// Icon image. |
|
38 |
@property(nonatomic, readonly, strong, nullable) GADNativeAdImage *icon; |
|
39 |
/// Description. |
|
40 |
@property(nonatomic, readonly, copy, nullable) NSString *body; |
|
41 |
/// Array of GADNativeAdImage objects. |
|
42 |
@property(nonatomic, readonly, strong, nullable) NSArray<GADNativeAdImage *> *images; |
|
43 |
/// App store rating (0 to 5). |
|
44 |
@property(nonatomic, readonly, copy, nullable) NSDecimalNumber *starRating; |
|
45 |
/// The app store name. For example, "App Store". |
|
46 |
@property(nonatomic, readonly, copy, nullable) NSString *store; |
|
47 |
/// String representation of the app's price. |
|
48 |
@property(nonatomic, readonly, copy, nullable) NSString *price; |
|
49 |
/// Identifies the advertiser. For example, the advertiser’s name or visible URL. |
|
50 |
@property(nonatomic, readonly, copy, nullable) NSString *advertiser; |
|
51 |
/// Media content. Set the associated media view's mediaContent property to this object to display |
|
52 |
/// this content. |
|
53 |
@property(nonatomic, readonly, nonnull) GADMediaContent *mediaContent; |
|
54 |
|
|
55 |
#pragma mark - Other properties |
|
56 |
|
|
57 |
/// Optional delegate to receive state change notifications. |
|
58 |
@property(nonatomic, weak, nullable) id<GADNativeAdDelegate> delegate; |
|
59 |
|
|
60 |
/// Reference to a root view controller that is used by the ad to present full screen content after |
|
61 |
/// the user interacts with the ad. The root view controller is most commonly the view controller |
|
62 |
/// displaying the ad. |
|
63 |
@property(nonatomic, weak, nullable) UIViewController *rootViewController; |
|
64 |
|
|
65 |
/// Dictionary of assets which aren't processed by the receiver. |
|
66 |
@property(nonatomic, readonly, copy, nullable) NSDictionary<NSString *, id> *extraAssets; |
|
67 |
|
|
68 |
/// Information about the ad response that returned the ad. |
|
69 |
@property(nonatomic, readonly, nonnull) GADResponseInfo *responseInfo; |
|
70 |
|
|
71 |
/// Called when the ad is estimated to have earned money. Available for allowlisted accounts only. |
|
72 |
@property(nonatomic, nullable, copy) GADPaidEventHandler paidEventHandler; |
|
73 |
|
|
74 |
/// Indicates whether custom Mute This Ad is available for the native ad. |
|
75 |
@property(nonatomic, readonly, getter=isCustomMuteThisAdAvailable) BOOL customMuteThisAdAvailable; |
|
76 |
|
|
77 |
/// An array of Mute This Ad reasons used to render customized mute ad survey. Use this array to |
|
78 |
/// implement your own Mute This Ad feature only when customMuteThisAdAvailable is YES. |
|
79 |
@property(nonatomic, readonly, nullable) NSArray<GADMuteThisAdReason *> *muteThisAdReasons; |
|
80 |
|
|
81 |
/// Registers ad view, clickable asset views, and nonclickable asset views with this native ad. |
|
82 |
/// Media view shouldn't be registered as clickable. |
|
83 |
/// @param clickableAssetViews Dictionary of asset views that are clickable, keyed by asset IDs. |
|
84 |
/// @param nonclickableAssetViews Dictionary of asset views that are not clickable, keyed by asset |
|
85 |
/// IDs. |
|
86 |
- (void)registerAdView:(nonnull UIView *)adView |
|
87 |
clickableAssetViews: |
|
88 |
(nonnull NSDictionary<GADNativeAssetIdentifier, UIView *> *)clickableAssetViews |
|
89 |
nonclickableAssetViews: |
|
90 |
(nonnull NSDictionary<GADNativeAssetIdentifier, UIView *> *)nonclickableAssetViews; |
|
91 |
|
|
92 |
/// Unregisters ad view from this native ad. The corresponding asset views will also be |
|
93 |
/// unregistered. |
|
94 |
- (void)unregisterAdView; |
|
95 |
|
|
96 |
/// Reports the mute event with the mute reason selected by user. Use nil if no reason was selected. |
|
97 |
/// Call this method only if customMuteThisAdAvailable is YES. |
|
98 |
- (void)muteThisAdWithReason:(nullable GADMuteThisAdReason *)reason; |
|
99 |
|
|
100 |
@end |
|
101 |
|
|
102 |
#pragma mark - Protocol and constants |
|
103 |
|
|
104 |
/// The delegate of a GADAdLoader object implements this protocol to receive GADNativeAd ads. |
|
105 |
@protocol GADNativeAdLoaderDelegate <GADAdLoaderDelegate> |
|
106 |
/// Called when a native ad is received. |
|
107 |
- (void)adLoader:(nonnull GADAdLoader *)adLoader didReceiveNativeAd:(nonnull GADNativeAd *)nativeAd; |
|
108 |
@end |
|
109 |
|
|
110 |
#pragma mark - Unified Native Ad View |
|
111 |
|
|
112 |
/// Base class for native ad views. Your native ad view must be a subclass of this class and must |
|
113 |
/// call superclass methods for all overridden methods. |
|
114 |
@interface GADNativeAdView : UIView |
|
115 |
|
|
116 |
/// This property must point to the native ad object rendered by this ad view. |
|
117 |
@property(nonatomic, strong, nullable) GADNativeAd *nativeAd; |
|
118 |
|
|
119 |
/// Weak reference to your ad view's headline asset view. |
|
120 |
@property(nonatomic, weak, nullable) IBOutlet UIView *headlineView; |
|
121 |
/// Weak reference to your ad view's call to action asset view. |
|
122 |
@property(nonatomic, weak, nullable) IBOutlet UIView *callToActionView; |
|
123 |
/// Weak reference to your ad view's icon asset view. |
|
124 |
@property(nonatomic, weak, nullable) IBOutlet UIView *iconView; |
|
125 |
/// Weak reference to your ad view's body asset view. |
|
126 |
@property(nonatomic, weak, nullable) IBOutlet UIView *bodyView; |
|
127 |
/// Weak reference to your ad view's store asset view. |
|
128 |
@property(nonatomic, weak, nullable) IBOutlet UIView *storeView; |
|
129 |
/// Weak reference to your ad view's price asset view. |
|
130 |
@property(nonatomic, weak, nullable) IBOutlet UIView *priceView; |
|
131 |
/// Weak reference to your ad view's image asset view. |
|
132 |
@property(nonatomic, weak, nullable) IBOutlet UIView *imageView; |
|
133 |
/// Weak reference to your ad view's star rating asset view. |
|
134 |
@property(nonatomic, weak, nullable) IBOutlet UIView *starRatingView; |
|
135 |
/// Weak reference to your ad view's advertiser asset view. |
|
136 |
@property(nonatomic, weak, nullable) IBOutlet UIView *advertiserView; |
|
137 |
/// Weak reference to your ad view's media asset view. |
|
138 |
@property(nonatomic, weak, nullable) IBOutlet GADMediaView *mediaView; |
|
139 |
/// Weak reference to your ad view's AdChoices view. Must set adChoicesView before setting |
|
140 |
/// nativeAd, otherwise AdChoices will be rendered according to the preferredAdChoicesPosition |
|
141 |
/// defined in GADNativeAdViewAdOptions. |
|
142 |
@property(nonatomic, weak, nullable) IBOutlet GADAdChoicesView *adChoicesView; |
|
143 |
|
|
144 |
@end |