Load a native ad with a swipe instead of a click iOS swift.

225 views
Skip to first unread message

Sunfocus Development Unit

unread,
Dec 19, 2022, 3:28:15 AM12/19/22
to Google Mobile Ads SDK Developers
Hello, 

I'm developing a Tinder like app where informations are displayed on cards than can be swiped left or right. Some of those cards are adverts, that I've implemented using NativeAd.

The advert can be launched if the media content or its button are clicked, but I would also like the ad to be launch if the card is swiped right. I have methods to detect a card has been swipe right or left, but I don't know how to launch the ad if the swiping right is detected.

If someone could help me on that, I would be very grateful.

Thanking you in advance.

Mobile Ads SDK Forum Advisor

unread,
Dec 19, 2022, 9:04:51 AM12/19/22
to developmen...@gmail.com, google-adm...@googlegroups.com

Hi there,

Thanks for reaching out to the GMA SDK Forum.

Kindly note that the Native ads are loaded with the GADAdLoader objects, which send messages to their delegates according to the GADAdLoaderDelegate protocol. Before you can load an ad, you have to initialize the ad loader. The following code demonstrates how to initialize a GADAdLoader:

adLoader = GADAdLoader(adUnitID: "ca-app-pub-3940256099942544/3986624511",

    rootViewController: self,

    adTypes: [ .native ],

    options: [ ... ad loader options objects ... ])

adLoader.delegate = self

 

 

Once your GADAdLoader is initialized, call its loadRequest: method to request an ad:

 

adLoader.load(GADRequest())

 

 

 

The loadRequest: method in GADAdLoader accepts the same GADRequest objects as banners and interstitials. You can use request objects to add targeting information, just as you would with other ad types.

Also, note that the Apps displaying native ads are free to request them in advance of when they'll actually be displayed. In many cases, this is the recommended practice. An app displaying a list of items with native ads mixed in, for example, can load native ads for the whole list, knowing that some will be shown only after the user scrolls the view and some may not be displayed at all.

Once you have loaded an ad, all that remains is to display it to your users. Head over to our Native Advanced guide to see how.

You may refer to documentation on iOS here  - https://developers.google.com/admob/ios/native/start#load_ads

In addition, you may refer to this iOS sample application if you need further implementation reference.

Let us know if you have any questions.

Regards,

Google Logo
Yasar
Mobile Ads SDK Team
 


ref:_00D1U1174p._5004Q2hLLVN:ref

Sunfocus Development Unit

unread,
Dec 20, 2022, 12:05:55 AM12/20/22
to Google Mobile Ads SDK Developers
Hi, 

Native ads are showing on my card view layout and I also implemented swipe feature. I want to implement tinder like functionality when user right swipe on google ads it will behave like user has clicked on ads and open in browser or something.

Mobile Ads SDK Forum Advisor

unread,
Dec 20, 2022, 8:13:42 AM12/20/22
to developmen...@gmail.com, google-adm...@googlegroups.com

Hi,

Thanks for getting back to us.

It’s good to know that Native ads are showing on your card view layout and also implemented a swipe feature. For your user case, have you tried to load an NativeAd as mentioned in the above post inside your right swipe function along with GADNativeAdCustomClickGestureOptions?

As per this guide, GADNativeAdCustomClickGestureOptions interface is for Ad loader options for custom click gestures. However, this is available for allowlisted publishers only, and these options will be ignored for publishers not allowlisted. Account manager should help to allowlist this ad loader options for the customer click gestures if you are not allowlisted.

You may call below loadRequest: method to request an ad after your GADAdLoader is initialized:

 

adLoader.load(GADRequest())

 

You may need to use nativeAd.delegate = self to be notified of events related to the native ad interactions, set the delegate property of the native ad. Then implement GADNativeAdDelegate to receive the following delegate calls:

 

func nativeAdDidRecordImpression(_ nativeAd: GADNativeAd) {

  // The native ad was shown.

}

 

func nativeAdDidRecordClick(_ nativeAd: GADNativeAd) {

  // The native ad was clicked on.

}

 

Let us know if this works for your user case. 

Regards,

Sunfocus Development Unit

unread,
Dec 20, 2022, 9:32:24 AM12/20/22
to Mobile Ads SDK Forum Advisor, google-adm...@googlegroups.com
Hi Team,

Thanks for the above help - I did the same implementation. Now How can i test the above implementation When I am passing GADNativeAdCustomClickGestureOoptions test ads stop showing.

Is there any further steps to get ourself registered for "allowlisted publishers"? 
What is steps to load only allowlisted publishers Ads?

Regards
--
Thanks & Regards,
Technical Architect
Sunfocus Solutions Pvt. Ltd.

Mobile Ads SDK Forum Advisor

unread,
Dec 20, 2022, 3:07:54 PM12/20/22
to developmen...@gmail.com, google-adm...@googlegroups.com
Hi Sunfocus,

I'm afraid that we don't have a visibility and control on allow-listing. What we do recommend is to reach out to your account manager as they are more equipped in handling this.

Regards,
Google Logo
Teejay Wennie
Mobile Ads SDK Team
 


ref:_00D1U1174p._5004Q2hLLVN:ref

Sunfocus Development Unit

unread,
Dec 21, 2022, 1:42:47 AM12/21/22
to Google Mobile Ads SDK Developers
Hi, 

What do mean by the account manager?  Are you talking about google adsense or something else? 


Here is my source code which I have implemented but in that case no ads are coming. 

  if adLoader == nil {             
           let gadAdLoaderOptions = GADNativeAdCustomClickGestureOptions.init(swipeGestureDirection: .right, tapsAllowed: true)                                      
           adLoader = GADAdLoader(adUnitID: adUnitID, rootViewController: self,  adTypes: [.native], options: [gadAdLoaderOptions])             
           adLoader.delegate = self        
       }                 
     adLoader.load(GADRequest())

Mobile Ads SDK Forum Advisor

unread,
Dec 21, 2022, 11:43:51 AM12/21/22
to developmen...@gmail.com, google-adm...@googlegroups.com
Hello,

Yes, I'm referring to them. You may also contact our Product support team via this link.
Reply all
Reply to author
Forward
0 new messages