commit | author | age
|
96fe76
|
1 |
// |
L |
2 |
// GADCustomNativeAd.h |
|
3 |
// Google Mobile Ads SDK |
|
4 |
// |
|
5 |
// Copyright 2015 Google LLC. All rights reserved. |
|
6 |
// |
|
7 |
|
|
8 |
#import <Foundation/Foundation.h> |
|
9 |
#import <GoogleMobileAds/GADAdLoaderDelegate.h> |
|
10 |
#import <GoogleMobileAds/GADDisplayAdMeasurement.h> |
|
11 |
#import <GoogleMobileAds/GADMediaView.h> |
|
12 |
#import <GoogleMobileAds/GADNativeAdImage.h> |
|
13 |
#import <GoogleMobileAds/GADResponseInfo.h> |
|
14 |
#import <GoogleMobileAds/GADVideoController.h> |
|
15 |
#import <UIKit/UIKit.h> |
|
16 |
|
|
17 |
/// Native ad custom click handler block. |assetID| is the ID of asset that has received a click. |
|
18 |
typedef void (^GADNativeAdCustomClickHandler)(NSString *_Nonnull assetID); |
|
19 |
|
|
20 |
/// Asset key for the GADMediaView asset view. |
|
21 |
FOUNDATION_EXPORT NSString *_Nonnull const GADCustomNativeAdMediaViewKey; |
|
22 |
|
|
23 |
@protocol GADCustomNativeAdDelegate; |
|
24 |
|
|
25 |
/// Custom native ad. To request this ad type, you need to pass |
|
26 |
/// GADAdLoaderAdTypeCustomNative (see GADAdLoaderAdTypes.h) to the |adTypes| parameter |
|
27 |
/// in GADAdLoader's initializer method. If you request this ad type, your delegate must conform to |
|
28 |
/// the GADCustomNativeAdLoaderDelegate protocol. |
|
29 |
@interface GADCustomNativeAd : NSObject |
|
30 |
|
|
31 |
/// The ad's format ID. |
|
32 |
@property(nonatomic, readonly, nonnull) NSString *formatID; |
|
33 |
|
|
34 |
/// Array of available asset keys. |
|
35 |
@property(nonatomic, readonly, nonnull) NSArray<NSString *> *availableAssetKeys; |
|
36 |
|
|
37 |
/// Custom click handler. Set this property only if this ad is configured with a custom click |
|
38 |
/// action, otherwise set it to nil. If this property is set to a non-nil value, the ad's built-in |
|
39 |
/// click actions are ignored and |customClickHandler| is executed when a click on the asset is |
|
40 |
/// received. |
|
41 |
@property(atomic, copy, nullable) GADNativeAdCustomClickHandler customClickHandler; |
|
42 |
|
|
43 |
/// The display ad measurement associated with this ad. |
|
44 |
@property(nonatomic, readonly, nullable) GADDisplayAdMeasurement *displayAdMeasurement; |
|
45 |
|
|
46 |
/// Media content. |
|
47 |
@property(nonatomic, readonly, nonnull) GADMediaContent *mediaContent; |
|
48 |
|
|
49 |
/// Optional delegate to receive state change notifications. |
|
50 |
@property(nonatomic, weak, nullable) id<GADCustomNativeAdDelegate> delegate; |
|
51 |
|
|
52 |
/// Reference to a root view controller that is used by the ad to present full screen content after |
|
53 |
/// the user interacts with the ad. The root view controller is most commonly the view controller |
|
54 |
/// displaying the ad. |
|
55 |
@property(nonatomic, weak, nullable) UIViewController *rootViewController; |
|
56 |
|
|
57 |
/// Information about the ad response that returned the ad. |
|
58 |
@property(nonatomic, readonly, nonnull) GADResponseInfo *responseInfo; |
|
59 |
|
|
60 |
/// Returns the native ad image corresponding to the specified key or nil if the image is not |
|
61 |
/// available. |
|
62 |
- (nullable GADNativeAdImage *)imageForKey:(nonnull NSString *)key; |
|
63 |
|
|
64 |
/// Returns the string corresponding to the specified key or nil if the string is not available. |
|
65 |
- (nullable NSString *)stringForKey:(nonnull NSString *)key; |
|
66 |
|
|
67 |
/// Call when the user clicks on the ad. Provide the asset key that best matches the asset the user |
|
68 |
/// interacted with. If this ad is configured with a custom click action, ensure the receiver's |
|
69 |
/// customClickHandler property is set before calling this method. |
|
70 |
- (void)performClickOnAssetWithKey:(nonnull NSString *)assetKey; |
|
71 |
|
|
72 |
/// Call when the ad is displayed on screen to the user. Can be called multiple times. Only the |
|
73 |
/// first impression is recorded. |
|
74 |
- (void)recordImpression; |
|
75 |
|
|
76 |
@end |
|
77 |
|
|
78 |
#pragma mark - Loading Protocol |
|
79 |
|
|
80 |
/// The delegate of a GADAdLoader object implements this protocol to receive |
|
81 |
/// GADCustomNativeAd ads. |
|
82 |
@protocol GADCustomNativeAdLoaderDelegate <GADAdLoaderDelegate> |
|
83 |
|
|
84 |
/// Called when requesting an ad. Asks the delegate for an array of custom native ad format ID |
|
85 |
/// strings. |
|
86 |
- (nonnull NSArray<NSString *> *)customNativeAdFormatIDsForAdLoader:(nonnull GADAdLoader *)adLoader; |
|
87 |
|
|
88 |
/// Tells the delegate that a custom native ad was received. |
|
89 |
- (void)adLoader:(nonnull GADAdLoader *)adLoader |
|
90 |
didReceiveCustomNativeAd:(nonnull GADCustomNativeAd *)customNativeAd; |
|
91 |
|
|
92 |
@end |