Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business

AdMobBannerNative

The AdMobBannerNative item allows monetizing your app with banner ads on Android and iOS. More...

Import Statement: import Felgo 4.0
Inherits:

NativeView

Properties

Signals

Detailed Description

Note: The AdMobBannerNative item is a replacement for the AdMobBanner item using Felgo's NativeView rendering, which supports displaying other QML items on top of it, z-ordering of items, using opacity, animations and all other QML item effects.

Ad banners can be used to display ads within your app without distracting your user from the app's main functionality. If you just want to include simple banner ads into your apps, Smart Banners are probably the right thing for you. They are versatile, support all device types and sizes and are really easy to use, see Example Usage for a simple example.

 import Felgo

 App {
   NavigationStack {
     AppPage {
       title: "Admob Banner"

       AdMobBannerNative {
         adUnitId: "ca-app-pub-3940256099942544/6300978111" // banner test ad by AdMob
         testDeviceIds: [ "<a testdevice id>" ]
         banner: AdMobBannerNative.BannerType.Smart

         anchors.horizontalCenter: parent.horizontalCenter
         anchors.top: parent.top
       }
     }
   }
 }

AdMob also offers a range of different-sized banners, which you can incorporate into your apps and games. Please note that some of the available sizes can only be used on tablets due to their dimensions.

Banners get only loaded if the QML item is visible, meaning that its visible property is not set to false and all its parent items are visible too.

If AdMobBannerNative.BannerType.Smart is set as banner type the banner will automatically resize to the full width on screen orientation changes.

For more information, also have a look at AdMob Plugin.

Note: AdMobBannerNative is rendered with OpenGL, and thus only works when enforcing OpenGL rendering. Add this code in your main.cpp, before creating QApplication (see also: Rendering Changes: Hardware Interface):

 QQuickWindow::setGraphicsApi(QSGRendererInterface::OpenGLRhi);

See also AdMobBanner.

Property Documentation

adUnitId : string

Provide your Ad unit ID retrieved from the AdMob console in the format ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx here. If you do not have an AdMob account yet, you can create a new one at http://www.google.com/ads/admob/. Once you are logged in, you can acquire a new Ad unit ID by creating a new app and defining a new ad unit.


This enum type defines what kind of banner should be displayed.

  • AdMobBannerNative.BannerType.Standard - A standard banner of size 320 x 50
  • AdMobBannerNative.BannerType.Large - A large banner of size 320x100
  • AdMobBannerNative.BannerType.Medium - A medium rectangle banner of size 300x250
  • AdMobBannerNative.BannerType.LeaderBoard - A leaderboard-sized banner of size 728x90
  • AdMobBannerNative.BannerType.Smart - A auto-resizing smart banner (recommended)

The default banner is AdMobBannerNative.BannerType.Smart.

Note: Please keep in mind that some banners might be too large for displaying on some devices and therefore won't be displayed. It's recommended to use the AdMobBannerNative.BannerType.Smart banner size for apps targeted for multiple device types.


childDirectedTreatment : bool

Set this property to true if you want to indicate that you want Google to treat your content as child-directed. Google will then take steps to disable IBA and remarketing ads for your ads.

More information can also be found here.


designedForFamilies : bool

Set this property to true if you have opted your app in to Google Play's Designed for Families program.

Note: This property is only applicable for Android. You need to ensure ads comply with the Designed for Families program requirements and ad policies.

More information can also be found here.


requestAdTrackingAuthorization : bool

Set this property to true to automatically request ad tracking authorization on iOS.

The item will ask the user for permission to use the advertising identifier (IDFA) before showing any ad. If the user accepts, ads may be attributed to the user and thus perform better.

The item still shows the ad even if the user denies the request.

To support the ad tracking authorization, adapt your ios/Project-Info.plist. Add the NSUserTrackingUsageDescription key with a description of usage. Example:

 <key>NSUserTrackingUsageDescription</key>
 <string>This identifier will be used to deliver personalized ads to you.</string>

You can find more information here.

Note: This property only has an effect on iOS and is ignored on other platforms.


testDeviceIds : var

Provide your device id as an array of string values here to receive test ads for the specific test devices.

Note: If you test your application with live ads frequently, Google might ban your account for fraud. Therefore if you are not able to provide the testDeviceIds and test with live ads instead, make sure not display the AdMob item everytime you test your app on your device.

You can find your testDeviceIds in the device log after you first run an your app with integrated AdMob plugin, search for "To get test ads on this device, call adRequest.addTestDevice".


Signal Documentation

adClicked()

This handler is called when the user clicks on an interactable element inside the ad banner.

Note: The corresponding handler is onAdClicked.


adClosed()

This handler is called when the application was moved to background to display an ad e.g. in the browser and the user returns from the browser.

Note: The corresponding handler is onAdClosed.


adFailedToReceive(string message)

This handler is called either because of a network error or when an ad should be displayed, but AdMob can't find an ad that fits your application. A possible reason for this can be the filter settings in your AdMob account, or that AdMob does not have any related ads in your country.

The parameter message contains information about the error that occured.

Note: The corresponding handler is onAdFailedToReceive.


adImpression()

This handler is called when the ad has recorded an impression from the user.

Note: The corresponding handler is onAdImpression.


adOpened()

This handler is called when a banner is clicked and e.g. a new browser window will be opened by the ad soon.

Note: The corresponding handler is onAdOpened.


adReceived()

This handler is called as soon as the requested ad is loaded and displayed on the screen.

Note: The corresponding handler is onAdReceived.


Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded