@capacitor-community/admob 3.0.1 → 3.3.0-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/LICENSE +1 -1
- package/README.md +137 -80
- package/android/build.gradle +11 -9
- package/android/src/main/java/com/getcapacitor/community/admob/AdMob.java +68 -15
- package/android/src/main/java/com/getcapacitor/community/admob/helpers/AuthorizationStatusEnum.kt +5 -0
- package/android/src/main/java/com/getcapacitor/community/admob/models/AdOptions.java +16 -2
- package/android/src/main/java/com/getcapacitor/community/admob/rewarded/AdRewardExecutor.java +1 -1
- package/android/src/main/java/com/getcapacitor/community/admob/rewarded/RewardedAdCallbackAndListeners.kt +14 -1
- package/android/src/main/java/com/getcapacitor/community/admob/rewarded/models/SsvInfo.kt +20 -0
- package/dist/docs.json +781 -92
- package/dist/esm/definitions.d.ts +50 -0
- package/dist/esm/definitions.js +19 -1
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/reward/index.d.ts +1 -0
- package/dist/esm/reward/index.js +1 -0
- package/dist/esm/reward/index.js.map +1 -1
- package/dist/esm/reward/reward-ad-options.interface.d.ts +25 -0
- package/dist/esm/reward/reward-ad-options.interface.js +2 -0
- package/dist/esm/reward/reward-ad-options.interface.js.map +1 -0
- package/dist/esm/reward/reward-definitions.interface.d.ts +4 -3
- package/dist/esm/shared/tracking-authorization-status.interface.d.ts +6 -0
- package/dist/esm/shared/tracking-authorization-status.interface.js +2 -0
- package/dist/esm/shared/tracking-authorization-status.interface.js.map +1 -0
- package/dist/esm/web.d.ts +3 -0
- package/dist/esm/web.js +8 -0
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +28 -0
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +29 -1
- package/dist/plugin.js.map +1 -1
- package/ios/Plugin/Banner/BannerExecutor.swift +1 -0
- package/ios/Plugin/Helper/AuthorizationStatusEnum.swift +6 -0
- package/ios/Plugin/Plugin.m +1 -0
- package/ios/Plugin/Plugin.swift +64 -3
- package/ios/Plugin/Rewarded/AdRewardExecutor.swift +17 -0
- package/package.json +4 -5
- package/ios/Plugin/.DS_Store +0 -0
|
@@ -3,6 +3,7 @@ package com.getcapacitor.community.admob.models;
|
|
|
3
3
|
import androidx.annotation.VisibleForTesting;
|
|
4
4
|
import com.getcapacitor.PluginCall;
|
|
5
5
|
import com.getcapacitor.community.admob.banner.BannerAdSizeEnum;
|
|
6
|
+
import com.getcapacitor.community.admob.rewarded.models.SsvInfo;
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Holds the options for an Ad Request
|
|
@@ -59,6 +60,11 @@ public abstract class AdOptions {
|
|
|
59
60
|
*/
|
|
60
61
|
public final boolean npa;
|
|
61
62
|
|
|
63
|
+
/**
|
|
64
|
+
* Used for Server side verification of Reward Ads
|
|
65
|
+
*/
|
|
66
|
+
public final SsvInfo ssvInfo;
|
|
67
|
+
|
|
62
68
|
private AdOptions(PluginCall call) {
|
|
63
69
|
/*
|
|
64
70
|
* TODO: Since the Id in the Typescript AdOptions interface is not optional
|
|
@@ -72,18 +78,20 @@ public abstract class AdOptions {
|
|
|
72
78
|
this.position = call.getString("position", "BOTTOM_CENTER");
|
|
73
79
|
this.margin = call.getInt("margin", 0);
|
|
74
80
|
this.npa = call.getBoolean("npa", false);
|
|
81
|
+
this.ssvInfo = new SsvInfo(call);
|
|
75
82
|
|
|
76
83
|
String sizeString = call.getString("adSize", BannerAdSizeEnum.ADAPTIVE_BANNER.name());
|
|
77
84
|
this.adSize = AdOptions.adSizeStringToAdSizeEnum(sizeString);
|
|
78
85
|
}
|
|
79
86
|
|
|
80
|
-
private AdOptions(String id, boolean isTesting, String position, int margin, boolean npa, BannerAdSizeEnum adSize) {
|
|
87
|
+
private AdOptions(String id, boolean isTesting, String position, int margin, boolean npa, BannerAdSizeEnum adSize, SsvInfo ssvInfo) {
|
|
81
88
|
this.adId = id;
|
|
82
89
|
this.isTesting = isTesting;
|
|
83
90
|
this.position = position;
|
|
84
91
|
this.margin = margin;
|
|
85
92
|
this.npa = npa;
|
|
86
93
|
this.adSize = adSize;
|
|
94
|
+
this.ssvInfo = ssvInfo;
|
|
87
95
|
}
|
|
88
96
|
|
|
89
97
|
/**
|
|
@@ -163,6 +171,12 @@ public abstract class AdOptions {
|
|
|
163
171
|
private int margin = 1;
|
|
164
172
|
private boolean npa = false;
|
|
165
173
|
private BannerAdSizeEnum adSize = BannerAdSizeEnum.ADAPTIVE_BANNER;
|
|
174
|
+
private SsvInfo ssvInfo = new SsvInfo();
|
|
175
|
+
|
|
176
|
+
public TesterAdOptionsBuilder setSsvInfo(SsvInfo info) {
|
|
177
|
+
ssvInfo = info;
|
|
178
|
+
return this;
|
|
179
|
+
}
|
|
166
180
|
|
|
167
181
|
public TesterAdOptionsBuilder setIsTesting(boolean value) {
|
|
168
182
|
isTesting = value;
|
|
@@ -200,7 +214,7 @@ public abstract class AdOptions {
|
|
|
200
214
|
}
|
|
201
215
|
|
|
202
216
|
public AdOptions build() {
|
|
203
|
-
return new AdOptions(id, isTesting, position, margin, npa, adSize) {
|
|
217
|
+
return new AdOptions(id, isTesting, position, margin, npa, adSize, ssvInfo) {
|
|
204
218
|
@Override
|
|
205
219
|
public String getTestingId() {
|
|
206
220
|
return testingID;
|
package/android/src/main/java/com/getcapacitor/community/admob/rewarded/AdRewardExecutor.java
CHANGED
|
@@ -43,7 +43,7 @@ public class AdRewardExecutor extends Executor {
|
|
|
43
43
|
contextSupplier.get(),
|
|
44
44
|
id,
|
|
45
45
|
adRequest,
|
|
46
|
-
RewardedAdCallbackAndListeners.INSTANCE.getRewardedAdLoadCallback(call, notifyListenersFunction)
|
|
46
|
+
RewardedAdCallbackAndListeners.INSTANCE.getRewardedAdLoadCallback(call, notifyListenersFunction, adOptions)
|
|
47
47
|
);
|
|
48
48
|
} catch (Exception ex) {
|
|
49
49
|
call.reject(ex.getLocalizedMessage(), ex);
|
|
@@ -4,11 +4,13 @@ import com.getcapacitor.JSObject
|
|
|
4
4
|
import com.getcapacitor.PluginCall
|
|
5
5
|
import com.getcapacitor.community.admob.helpers.FullscreenPluginCallback
|
|
6
6
|
import com.getcapacitor.community.admob.models.AdMobPluginError
|
|
7
|
+
import com.getcapacitor.community.admob.models.AdOptions
|
|
7
8
|
import com.google.android.gms.ads.LoadAdError
|
|
8
9
|
import com.google.android.gms.ads.OnUserEarnedRewardListener
|
|
9
10
|
import com.google.android.gms.ads.rewarded.RewardItem
|
|
10
11
|
import com.google.android.gms.ads.rewarded.RewardedAd
|
|
11
12
|
import com.google.android.gms.ads.rewarded.RewardedAdLoadCallback
|
|
13
|
+
import com.google.android.gms.ads.rewarded.ServerSideVerificationOptions
|
|
12
14
|
import com.google.android.gms.common.util.BiConsumer
|
|
13
15
|
|
|
14
16
|
object RewardedAdCallbackAndListeners {
|
|
@@ -23,13 +25,24 @@ object RewardedAdCallbackAndListeners {
|
|
|
23
25
|
}
|
|
24
26
|
}
|
|
25
27
|
|
|
26
|
-
fun getRewardedAdLoadCallback(call: PluginCall, notifyListenersFunction: BiConsumer<String, JSObject
|
|
28
|
+
fun getRewardedAdLoadCallback(call: PluginCall, notifyListenersFunction: BiConsumer<String, JSObject>, adOptions: AdOptions): RewardedAdLoadCallback {
|
|
27
29
|
return object : RewardedAdLoadCallback() {
|
|
28
30
|
override fun onAdLoaded(ad: RewardedAd) {
|
|
29
31
|
AdRewardExecutor.mRewardedAd = ad
|
|
30
32
|
AdRewardExecutor.mRewardedAd.fullScreenContentCallback = FullscreenPluginCallback(
|
|
31
33
|
RewardAdPluginEvents, notifyListenersFunction)
|
|
32
34
|
|
|
35
|
+
if(adOptions.ssvInfo.hasInfo){
|
|
36
|
+
val ssvOptions = ServerSideVerificationOptions.Builder()
|
|
37
|
+
adOptions.ssvInfo.customData?.let {
|
|
38
|
+
ssvOptions.setCustomData(it)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
adOptions.ssvInfo.userId?.let {
|
|
42
|
+
ssvOptions.setUserId(it)
|
|
43
|
+
}
|
|
44
|
+
AdRewardExecutor.mRewardedAd.setServerSideVerificationOptions(ssvOptions.build())
|
|
45
|
+
}
|
|
33
46
|
|
|
34
47
|
val adInfo = JSObject()
|
|
35
48
|
adInfo.put("adUnitId", ad.adUnitId)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
package com.getcapacitor.community.admob.rewarded.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
|
+
}
|