@capacitor-community/admob 5.3.1 → 6.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CapacitorCommunityAdmob.podspec +1 -1
- package/README.md +292 -87
- package/android/build.gradle +6 -6
- package/android/src/main/java/com/getcapacitor/community/admob/AdMob.java +17 -0
- package/android/src/main/java/com/getcapacitor/community/admob/models/AdOptions.java +10 -0
- package/android/src/main/java/com/getcapacitor/community/admob/rewardedinterstitial/AdRewardInterstitialExecutor.java +84 -0
- package/android/src/main/java/com/getcapacitor/community/admob/rewardedinterstitial/RewardInterstitialAdPluginEvents.kt +12 -0
- package/android/src/main/java/com/getcapacitor/community/admob/rewardedinterstitial/RewardedInterstitialAdCallbackAndListeners.kt +50 -0
- package/android/src/main/java/com/getcapacitor/community/admob/rewardedinterstitial/models/SsvInfo.kt +20 -0
- package/dist/docs.json +374 -34
- package/dist/esm/banner/banner-definitions.interface.d.ts +18 -18
- package/dist/esm/definitions.d.ts +2 -1
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/interstitial/interstitial-definitions.interface.d.ts +5 -5
- package/dist/esm/private/validate-all-events-implemented.type.d.ts +1 -1
- package/dist/esm/reward/reward-definitions.interface.d.ts +12 -12
- package/dist/esm/reward-interstitial/index.d.ts +4 -0
- package/dist/esm/reward-interstitial/index.js +5 -0
- package/dist/esm/reward-interstitial/index.js.map +1 -0
- package/dist/esm/reward-interstitial/reward-interstitial-ad-options.interface.d.ts +25 -0
- package/dist/esm/reward-interstitial/reward-interstitial-ad-options.interface.js +2 -0
- package/dist/esm/reward-interstitial/reward-interstitial-ad-options.interface.js.map +1 -0
- package/dist/esm/reward-interstitial/reward-interstitial-ad-plugin-events.enum.d.ts +32 -0
- package/dist/esm/reward-interstitial/reward-interstitial-ad-plugin-events.enum.js +35 -0
- package/dist/esm/reward-interstitial/reward-interstitial-ad-plugin-events.enum.js.map +1 -0
- package/dist/esm/reward-interstitial/reward-interstitial-definitions.interface.d.ts +30 -0
- package/dist/esm/reward-interstitial/reward-interstitial-definitions.interface.js +2 -0
- package/dist/esm/reward-interstitial/reward-interstitial-definitions.interface.js.map +1 -0
- package/dist/esm/reward-interstitial/reward-interstitial-item.interface.d.ts +14 -0
- package/dist/esm/reward-interstitial/reward-interstitial-item.interface.js +2 -0
- package/dist/esm/reward-interstitial/reward-interstitial-item.interface.js.map +1 -0
- package/dist/esm/web.d.ts +2 -2
- package/dist/esm/web.js +12 -9
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +47 -9
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +47 -9
- package/dist/plugin.js.map +1 -1
- package/ios/Plugin/Banner/BannerExecutor.swift +11 -23
- package/ios/Plugin/Consent/ConsentExecutor.swift +1 -1
- package/ios/Plugin/Interstitial/AdInterstitialExecutor.swift +4 -4
- package/ios/Plugin/Plugin.m +2 -0
- package/ios/Plugin/Plugin.swift +28 -6
- package/ios/Plugin/Rewarded/AdRewardExecutor.swift +4 -4
- package/ios/Plugin/RewardedInterstitial/AdRewardInterstitialExecutor.swift +86 -0
- package/ios/Plugin/RewardedInterstitial/RewardInterstitialAdPluginEvents.swift +8 -0
- package/package.json +9 -9
package/android/build.gradle
CHANGED
|
@@ -4,18 +4,18 @@ ext {
|
|
|
4
4
|
androidxCoordinatorLayoutVersion = project.hasProperty('androidxCoordinatorLayoutVersion') ? rootProject.ext.androidxCoordinatorLayoutVersion : '1.2.0'
|
|
5
5
|
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.5'
|
|
6
6
|
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.5.1'
|
|
7
|
-
playServicesAdsVersion = project.hasProperty('playServicesAdsVersion') ? rootProject.ext.playServicesAdsVersion : '
|
|
8
|
-
androidxCoreKTXVersion = project.hasProperty('androidxCoreKTXVersion') ? rootProject.ext.androidxCoreKTXVersion : '1.
|
|
7
|
+
playServicesAdsVersion = project.hasProperty('playServicesAdsVersion') ? rootProject.ext.playServicesAdsVersion : '23.0.0'
|
|
8
|
+
androidxCoreKTXVersion = project.hasProperty('androidxCoreKTXVersion') ? rootProject.ext.androidxCoreKTXVersion : '1.13.0'
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
buildscript {
|
|
12
|
-
ext.kotlin_version = project.hasProperty("kotlin_version") ? rootProject.ext.kotlin_version : '1.
|
|
12
|
+
ext.kotlin_version = project.hasProperty("kotlin_version") ? rootProject.ext.kotlin_version : '1.9.10'
|
|
13
13
|
repositories {
|
|
14
14
|
google()
|
|
15
15
|
mavenCentral()
|
|
16
16
|
}
|
|
17
17
|
dependencies {
|
|
18
|
-
classpath 'com.android.tools.build:gradle:8.
|
|
18
|
+
classpath 'com.android.tools.build:gradle:8.2.1'
|
|
19
19
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
|
20
20
|
}
|
|
21
21
|
}
|
|
@@ -25,10 +25,10 @@ apply plugin: 'kotlin-android'
|
|
|
25
25
|
|
|
26
26
|
android {
|
|
27
27
|
namespace "com.getcapacitor.community.admob.admob"
|
|
28
|
-
|
|
28
|
+
compileSdk project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 34
|
|
29
29
|
defaultConfig {
|
|
30
30
|
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 22
|
|
31
|
-
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion :
|
|
31
|
+
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 34
|
|
32
32
|
versionCode 1
|
|
33
33
|
versionName "1.0"
|
|
34
34
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
|
@@ -14,6 +14,7 @@ import com.getcapacitor.community.admob.helpers.AuthorizationStatusEnum;
|
|
|
14
14
|
import com.getcapacitor.community.admob.interstitial.AdInterstitialExecutor;
|
|
15
15
|
import com.getcapacitor.community.admob.interstitial.InterstitialAdCallbackAndListeners;
|
|
16
16
|
import com.getcapacitor.community.admob.rewarded.AdRewardExecutor;
|
|
17
|
+
import com.getcapacitor.community.admob.rewardedinterstitial.AdRewardInterstitialExecutor;
|
|
17
18
|
import com.google.android.gms.ads.MobileAds;
|
|
18
19
|
import com.google.android.gms.ads.RequestConfiguration;
|
|
19
20
|
import com.google.android.gms.ads.initialization.InitializationStatus;
|
|
@@ -39,6 +40,12 @@ public class AdMob extends Plugin {
|
|
|
39
40
|
this::notifyListeners,
|
|
40
41
|
getLogTag()
|
|
41
42
|
);
|
|
43
|
+
private final AdRewardInterstitialExecutor adRewardInterstitialExecutor = new AdRewardInterstitialExecutor(
|
|
44
|
+
this::getContext,
|
|
45
|
+
this::getActivity,
|
|
46
|
+
this::notifyListeners,
|
|
47
|
+
getLogTag()
|
|
48
|
+
);
|
|
42
49
|
private final AdInterstitialExecutor adInterstitialExecutor = new AdInterstitialExecutor(
|
|
43
50
|
this::getContext,
|
|
44
51
|
this::getActivity,
|
|
@@ -169,6 +176,16 @@ public class AdMob extends Plugin {
|
|
|
169
176
|
adRewardExecutor.showRewardVideoAd(call, this::notifyListeners);
|
|
170
177
|
}
|
|
171
178
|
|
|
179
|
+
@PluginMethod
|
|
180
|
+
public void prepareRewardInterstitialAd(final PluginCall call) {
|
|
181
|
+
adRewardInterstitialExecutor.prepareRewardInterstitialAd(call, this::notifyListeners);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
@PluginMethod
|
|
185
|
+
public void showRewardInterstitialAd(final PluginCall call) {
|
|
186
|
+
adRewardInterstitialExecutor.showRewardInterstitialAd(call, this::notifyListeners);
|
|
187
|
+
}
|
|
188
|
+
|
|
172
189
|
/**
|
|
173
190
|
* @see <a href="https://developers.google.com/admob/android/test-ads#enable_test_devices">Test Devices</a>
|
|
174
191
|
* @see <a href="https://developers.google.com/admob/android/targeting">Target Settings</a>
|
|
@@ -27,6 +27,7 @@ public abstract class AdOptions {
|
|
|
27
27
|
public static final String BANNER_TESTER_ID = "ca-app-pub-3940256099942544/6300978111";
|
|
28
28
|
public static final String INTERSTITIAL_TESTER_ID = "ca-app-pub-3940256099942544/1033173712";
|
|
29
29
|
public static final String REWARD_VIDEO_TESTER_ID = "ca-app-pub-3940256099942544/5224354917";
|
|
30
|
+
public static final String REWARD_INTERSTITIAL_TESTER_ID = "ca-app-pub-3940256099942544/5354046379";
|
|
30
31
|
|
|
31
32
|
/**
|
|
32
33
|
* The position of the ad, it can be TOP_CENTER,
|
|
@@ -138,6 +139,15 @@ public abstract class AdOptions {
|
|
|
138
139
|
};
|
|
139
140
|
}
|
|
140
141
|
|
|
142
|
+
public AdOptions createRewardInterstitialOptions(PluginCall call) {
|
|
143
|
+
return new AdOptions(call) {
|
|
144
|
+
@Override
|
|
145
|
+
public String getTestingId() {
|
|
146
|
+
return AdOptions.REWARD_INTERSTITIAL_TESTER_ID;
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
|
|
141
151
|
public AdOptions createGenericOptions(PluginCall call, final String testingID) {
|
|
142
152
|
return new AdOptions(call) {
|
|
143
153
|
@Override
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
package com.getcapacitor.community.admob.rewardedinterstitial;
|
|
2
|
+
|
|
3
|
+
import android.app.Activity;
|
|
4
|
+
import android.content.Context;
|
|
5
|
+
import androidx.core.util.Supplier;
|
|
6
|
+
import com.getcapacitor.JSObject;
|
|
7
|
+
import com.getcapacitor.PluginCall;
|
|
8
|
+
import com.getcapacitor.PluginMethod;
|
|
9
|
+
import com.getcapacitor.community.admob.helpers.AdViewIdHelper;
|
|
10
|
+
import com.getcapacitor.community.admob.helpers.RequestHelper;
|
|
11
|
+
import com.getcapacitor.community.admob.models.AdMobPluginError;
|
|
12
|
+
import com.getcapacitor.community.admob.models.AdOptions;
|
|
13
|
+
import com.getcapacitor.community.admob.models.Executor;
|
|
14
|
+
import com.google.android.gms.ads.AdRequest;
|
|
15
|
+
import com.google.android.gms.ads.rewardedinterstitial.RewardedInterstitialAd;
|
|
16
|
+
import com.google.android.gms.common.util.BiConsumer;
|
|
17
|
+
|
|
18
|
+
public class AdRewardInterstitialExecutor extends Executor {
|
|
19
|
+
|
|
20
|
+
public static RewardedInterstitialAd mRewardedInterstitialAd;
|
|
21
|
+
|
|
22
|
+
public AdRewardInterstitialExecutor(
|
|
23
|
+
Supplier<Context> contextSupplier,
|
|
24
|
+
Supplier<Activity> activitySupplier,
|
|
25
|
+
BiConsumer<String, JSObject> notifyListenersFunction,
|
|
26
|
+
String pluginLogTag
|
|
27
|
+
) {
|
|
28
|
+
super(contextSupplier, activitySupplier, notifyListenersFunction, pluginLogTag, "AdRewardExecutor");
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@PluginMethod
|
|
32
|
+
public void prepareRewardInterstitialAd(final PluginCall call, BiConsumer<String, JSObject> notifyListenersFunction) {
|
|
33
|
+
final AdOptions adOptions = AdOptions.getFactory().createRewardInterstitialOptions(call);
|
|
34
|
+
|
|
35
|
+
activitySupplier
|
|
36
|
+
.get()
|
|
37
|
+
.runOnUiThread(
|
|
38
|
+
() -> {
|
|
39
|
+
try {
|
|
40
|
+
final AdRequest adRequest = RequestHelper.createRequest(adOptions);
|
|
41
|
+
final String id = AdViewIdHelper.getFinalAdId(adOptions, adRequest, logTag, contextSupplier.get());
|
|
42
|
+
RewardedInterstitialAd.load(
|
|
43
|
+
contextSupplier.get(),
|
|
44
|
+
id,
|
|
45
|
+
adRequest,
|
|
46
|
+
RewardedInterstitialAdCallbackAndListeners.INSTANCE.getRewardedAdLoadCallback(
|
|
47
|
+
call,
|
|
48
|
+
notifyListenersFunction,
|
|
49
|
+
adOptions
|
|
50
|
+
)
|
|
51
|
+
);
|
|
52
|
+
} catch (Exception ex) {
|
|
53
|
+
call.reject(ex.getLocalizedMessage(), ex);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
@PluginMethod
|
|
60
|
+
public void showRewardInterstitialAd(final PluginCall call, BiConsumer<String, JSObject> notifyListenersFunction) {
|
|
61
|
+
if (mRewardedInterstitialAd == null) {
|
|
62
|
+
String errorMessage = "No Reward Video Ad can be show. It was not prepared or maybe it failed to be prepared.";
|
|
63
|
+
call.reject(errorMessage);
|
|
64
|
+
AdMobPluginError errorObject = new AdMobPluginError(-1, errorMessage);
|
|
65
|
+
notifyListenersFunction.accept(RewardInterstitialAdPluginEvents.FailedToLoad, errorObject);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
try {
|
|
70
|
+
activitySupplier
|
|
71
|
+
.get()
|
|
72
|
+
.runOnUiThread(
|
|
73
|
+
() -> {
|
|
74
|
+
mRewardedInterstitialAd.show(
|
|
75
|
+
activitySupplier.get(),
|
|
76
|
+
RewardedInterstitialAdCallbackAndListeners.INSTANCE.getOnUserEarnedRewardListener(call, notifyListenersFunction)
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
);
|
|
80
|
+
} catch (Exception ex) {
|
|
81
|
+
call.reject(ex.getLocalizedMessage(), ex);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
package com.getcapacitor.community.admob.rewardedinterstitial
|
|
2
|
+
|
|
3
|
+
import com.getcapacitor.community.admob.models.LoadPluginEventNames
|
|
4
|
+
|
|
5
|
+
object RewardInterstitialAdPluginEvents: LoadPluginEventNames {
|
|
6
|
+
const val Loaded = "onRewardedInterstitialAdLoaded"
|
|
7
|
+
const val FailedToLoad = "onRewardedInterstitialAdFailedToLoad"
|
|
8
|
+
const val Rewarded = "onRewardedInterstitialAdReward"
|
|
9
|
+
override val Showed = "onRewardedInterstitialAdShowed"
|
|
10
|
+
override val FailedToShow = "onRewardedInterstitialAdFailedToShow"
|
|
11
|
+
override val Dismissed = "onRewardedInterstitialAdDismissed"
|
|
12
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
package com.getcapacitor.community.admob.rewardedinterstitial
|
|
2
|
+
|
|
3
|
+
import com.getcapacitor.JSObject
|
|
4
|
+
import com.getcapacitor.PluginCall
|
|
5
|
+
import com.getcapacitor.community.admob.helpers.FullscreenPluginCallback
|
|
6
|
+
import com.getcapacitor.community.admob.models.AdMobPluginError
|
|
7
|
+
import com.getcapacitor.community.admob.models.AdOptions
|
|
8
|
+
import com.google.android.gms.ads.LoadAdError
|
|
9
|
+
import com.google.android.gms.ads.OnUserEarnedRewardListener
|
|
10
|
+
import com.google.android.gms.ads.rewarded.RewardItem
|
|
11
|
+
import com.google.android.gms.ads.rewardedinterstitial.RewardedInterstitialAd
|
|
12
|
+
import com.google.android.gms.ads.rewardedinterstitial.RewardedInterstitialAdLoadCallback
|
|
13
|
+
import com.google.android.gms.common.util.BiConsumer
|
|
14
|
+
|
|
15
|
+
object RewardedInterstitialAdCallbackAndListeners {
|
|
16
|
+
|
|
17
|
+
fun getOnUserEarnedRewardListener(call: PluginCall, notifyListenersFunction: BiConsumer<String, JSObject>): OnUserEarnedRewardListener {
|
|
18
|
+
return OnUserEarnedRewardListener { item: RewardItem ->
|
|
19
|
+
val response = JSObject()
|
|
20
|
+
response.put("type", item.type)
|
|
21
|
+
.put("amount", item.amount)
|
|
22
|
+
notifyListenersFunction.accept(RewardInterstitialAdPluginEvents.Rewarded, response)
|
|
23
|
+
call.resolve(response)
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
fun getRewardedAdLoadCallback(call: PluginCall, notifyListenersFunction: BiConsumer<String, JSObject>, adOptions: AdOptions): RewardedInterstitialAdLoadCallback {
|
|
28
|
+
return object : RewardedInterstitialAdLoadCallback() {
|
|
29
|
+
override fun onAdLoaded(ad: RewardedInterstitialAd) {
|
|
30
|
+
AdRewardInterstitialExecutor.mRewardedInterstitialAd = ad
|
|
31
|
+
AdRewardInterstitialExecutor.mRewardedInterstitialAd.fullScreenContentCallback = FullscreenPluginCallback(
|
|
32
|
+
RewardInterstitialAdPluginEvents, notifyListenersFunction)
|
|
33
|
+
|
|
34
|
+
val adInfo = JSObject()
|
|
35
|
+
adInfo.put("adUnitId", ad.adUnitId)
|
|
36
|
+
call.resolve(adInfo)
|
|
37
|
+
|
|
38
|
+
notifyListenersFunction.accept(RewardInterstitialAdPluginEvents.Loaded, adInfo)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
override fun onAdFailedToLoad(adError: LoadAdError) {
|
|
42
|
+
val adMobError = AdMobPluginError(adError)
|
|
43
|
+
|
|
44
|
+
notifyListenersFunction.accept(RewardInterstitialAdPluginEvents.FailedToLoad, adMobError)
|
|
45
|
+
call.reject(adError.message)
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
package com.getcapacitor.community.admob.rewardedinterstitial.models
|
|
2
|
+
|
|
3
|
+
import com.getcapacitor.PluginCall
|
|
4
|
+
|
|
5
|
+
class SsvInfo(
|
|
6
|
+
val customData: String? = null,
|
|
7
|
+
val userId: String? = null) {
|
|
8
|
+
|
|
9
|
+
constructor(pluginCall: PluginCall?) : this(
|
|
10
|
+
pluginCall?.getObject("ssv")?.getString("customData"),
|
|
11
|
+
pluginCall?.getObject("ssv")?.getString("userId")
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
constructor() : this(null, null)
|
|
15
|
+
|
|
16
|
+
val hasInfo
|
|
17
|
+
get(): Boolean {
|
|
18
|
+
return customData != null || userId != null
|
|
19
|
+
}
|
|
20
|
+
}
|