react中定时器的应用

This post is done on a special request from one of our readers. If you have more requests, let me know in the comments.

这篇文章是应一位读者的特殊要求完成的。 如果您有更多要求,请在评论中告诉我。

In this post, you will learn how to implement AdMob functionality, i.e. Google advertisements, in Ionic React Capacitor apps. We will implement this in a simple Ionic App and test on the iOS simulator and Android device.

在本文中,您将学习如何在Ionic React Capacitor应用程序中实现AdMob功能,即Google广告。 我们将在一个简单的Ionic App中实现此功能,并在iOS模拟器和Android设备上进行测试。

什么是Admob? (What is Admob?)

As we all know, advertisements are the major source of income for all tech giants like Google, Facebook, Twitter etc. Google ads are one of the most popular ads out there, and the mobile version of Google ads is what they call AdMob.

众所周知,广告是所有科技巨头(例如Google,Facebook,Twitter等)的主要收入来源。Google广告是目前最受欢迎的广告之一,而移动版的Google广告被称为AdMob。

An example of Google AdMob ad. The ad is prompting user to install certain app
Google AdMob广告的示例。 广告提示用户安装某些应用

AdMob广告类型 (Type of AdMob ads)

Banner: A basic ad format that appears at the top & bottom of the device screen.

标语 :出现在设备屏幕顶部和底部的基本广告格式。

Interstitial: Full-page ads appear at natural breaks & transitions, such as level completion. Supports video content.

插页式 :整页广告会在自然休息和过渡(例如关卡完成)时出现。 支持视频内容。

Rewarded: Full page Ads reward users for watching short videos and interacting with playable ads and surveys. Good for monetizing free-to-play users. Supports video content.

奖励页广告奖励观看短视频并与可播放的广告和调查进行互动的用户。 适用于通过免费游戏用户获利。 支持视频内容。

Native: Customizable ad format that matches the look & feel of your app. Ads appear inline with app content. Supports video content. For now, Native ads are only possible in Native apps, not in hybrid apps like the ones based on Ionic or React Native.

原生 :与您的应用外观相匹配的可自定义广告格式。 广告与应用程序内容内联显示。 支持视频内容。 目前,原生广告只能在原生应用中使用,而不能在基于Ionic或React Native的混合应用中使用。

Let us look at the underlying frameworks for this post. If you are conversant with Ionic and Capacitor, skip these sections and go to the code segment of the post.

让我们看一下这篇文章的底层框架。 如果您熟悉Ionic和Capacitor,请跳过这些部分,然后转到文章的代码段。

免责声明 (Disclaimer)

Since this post is a mix of three frameworks, it is possible you landed here by mistake. If you are looking for AdMob login in

由于这篇文章是三个框架的混合,因此您可能会误入这里。 如果您正在寻找AdMob登录