|
| 1 | +// |
| 2 | +// Copyright (C) 2026 Google, Inc. |
| 3 | +// |
| 4 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +// you may not use this file except in compliance with the License. |
| 6 | +// You may obtain a copy of the License at |
| 7 | +// |
| 8 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +// |
| 10 | +// Unless required by applicable law or agreed to in writing, software |
| 11 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +// See the License for the specific language governing permissions and |
| 14 | +// limitations under the License. |
| 15 | +// |
| 16 | + |
| 17 | +#import <UIKit/UIKit.h> |
| 18 | +#import <GoogleMobileAds/GoogleMobileAds.h> |
| 19 | + |
| 20 | +NS_ASSUME_NONNULL_BEGIN |
| 21 | + |
| 22 | +// Replace this ad unit ID with your own ad unit ID. |
| 23 | +static NSString *const kNativeAdUnitID = @"/21775744923/example/native"; |
| 24 | + |
| 25 | +// Demonstrates how to use custom click gesture options for native ads in Google Ad Manager. |
| 26 | +@interface AdManagerNativeAdOptionsSnippets : UIViewController <GADNativeAdDelegate> |
| 27 | +// The ad loader. |
| 28 | +@property(nonatomic, strong) GADAdLoader *adLoader; |
| 29 | +@end |
| 30 | + |
| 31 | +@implementation AdManagerNativeAdOptionsSnippets |
| 32 | + |
| 33 | +// Sets up a GADAdLoader with custom swipe gesture options. |
| 34 | +- (void)setCustomSwipeGesture { |
| 35 | + // [START set_custom_swipe_gesture] |
| 36 | + GADNativeAdCustomClickGestureOptions *swipeGestureOptions = |
| 37 | + [[GADNativeAdCustomClickGestureOptions alloc] |
| 38 | + initWithSwipeGestureDirection:UISwipeGestureRecognizerDirectionRight |
| 39 | + tapsAllowed:YES]; |
| 40 | + |
| 41 | + self.adLoader = [[GADAdLoader alloc] initWithAdUnitID:kNativeAdUnitID |
| 42 | + rootViewController:self |
| 43 | + adTypes:@[ GADAdLoaderAdTypeNative ] |
| 44 | + options:@[ swipeGestureOptions ]]; |
| 45 | + // [END set_custom_swipe_gesture] |
| 46 | +} |
| 47 | + |
| 48 | +#pragma mark - GADNativeAdDelegate |
| 49 | + |
| 50 | +// Called when a swipe gesture click is recorded, as configured in |
| 51 | +// GADNativeAdCustomClickGestureOptions. |
| 52 | +// [START custom_swipe_gesture_delegate] |
| 53 | +- (void)nativeAdDidRecordSwipeGestureClick:(GADNativeAd *)nativeAd { |
| 54 | + NSLog(@"A swipe gesture click has occurred."); |
| 55 | +} |
| 56 | + |
| 57 | +// Called when a swipe gesture click or a tap click is recorded. |
| 58 | +- (void)nativeAdDidRecordClick:(GADNativeAd *)nativeAd { |
| 59 | + NSLog(@"A swipe gesture click or tap click has occurred."); |
| 60 | +} |
| 61 | +// [END custom_swipe_gesture_delegate] |
| 62 | + |
| 63 | +@end |
| 64 | + |
| 65 | +NS_ASSUME_NONNULL_END |
0 commit comments