emi-indo-cordova-plugin-admob 1.4.3 → 1.4.5
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/README.md +456 -219
- package/example/Advanced topics/globalSettings.html +1 -0
- package/example/banner_ads.html +15 -1
- package/example/wewrtr.html +0 -0
- package/package.json +1 -1
- package/plugin.xml +1 -1
- package/src/android/emiAdmobPlugin.java +1 -1
- package/src/ios/emiAdmobPlugin.h +1 -0
- package/src/ios/emiAdmobPlugin.m +2622 -501
- package/www/emiAdmobPlugin.js +15 -16
package/src/ios/emiAdmobPlugin.m
CHANGED
@@ -1,523 +1,2644 @@
|
|
1
1
|
#import "emiAdmobPlugin.h"
|
2
|
-
#import <Cordova/CDVPlugin.h>
|
3
|
-
#import <UserMessagingPlatform/UserMessagingPlatform.h>
|
4
|
-
#import <AppTrackingTransparency/AppTrackingTransparency.h>
|
5
2
|
#import <AdSupport/AdSupport.h>
|
3
|
+
#import <AppTrackingTransparency/AppTrackingTransparency.h>
|
4
|
+
#import <Cordova/CDVPlugin.h>
|
6
5
|
#import <Foundation/Foundation.h>
|
7
|
-
|
6
|
+
#import <UserMessagingPlatform/UserMessagingPlatform.h>
|
7
|
+
@implementation
|
8
|
+
emiAdmobPlugin
|
8
9
|
@synthesize appOpenAd;
|
9
|
-
@synthesize
|
10
|
-
|
11
|
-
@synthesize
|
12
|
-
|
10
|
+
@synthesize
|
11
|
+
bannerView;
|
12
|
+
@synthesize
|
13
|
+
interstitial;
|
14
|
+
@synthesize
|
15
|
+
rewardedInterstitialAd;
|
16
|
+
@synthesize
|
17
|
+
rewardedAd;
|
13
18
|
@synthesize command;
|
14
|
-
@synthesize
|
15
|
-
|
19
|
+
@synthesize
|
20
|
+
responseInfo;
|
21
|
+
@synthesize
|
22
|
+
isPrivacyOptionsRequired;
|
16
23
|
int idfaStatus = 0;
|
17
24
|
int fromStatus = 0;
|
25
|
+
int Consent_Status
|
26
|
+
= 0;
|
18
27
|
int adFormat = 0;
|
19
28
|
int adWidth = 320;
|
20
29
|
BOOL auto_Show = NO;
|
21
30
|
NSString *Npa = @"1";
|
22
|
-
NSString *Position
|
23
|
-
|
24
|
-
BOOL
|
31
|
+
NSString *Position
|
32
|
+
= @"bottom";
|
33
|
+
BOOL EnableCollapsible
|
34
|
+
= NO;
|
35
|
+
BOOL ResponseInfo
|
36
|
+
= NO;
|
25
37
|
int isAdSkip = 0;
|
26
38
|
BOOL isIAB = NO;
|
27
|
-
BOOL UnderAgeOfConsent
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
} [self fireEvent:@"" event:@"on.get.from.status" withData:nil]; }]; }]; pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt:fromStatus]; [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
69
|
-
}- (void)showPrivacyOptionsForm:(CDVInvokedUrlCommand*)command { UMPRequestParameters *parameters = [[UMPRequestParameters alloc] init];
|
70
|
-
// UMPDebugSettings *debugSettings = [[UMPDebugSettings alloc] init];
|
71
|
-
// debugSettings.testDeviceIdentifiers = @[@"59156CDC-B042-4D81-A9FA-900869782912"];
|
72
|
-
// parameters.debugSettings = debugSettings;
|
73
|
-
// debugSettings.geography = UMPDebugGeographyEEA;
|
74
|
-
// BOOL tagForUnderAgeOfConsent = [[command argumentAtIndex:0] boolValue];
|
75
|
-
parameters.tagForUnderAgeOfConsent = UnderAgeOfConsent;
|
76
|
-
[UMPConsentInformation.sharedInstance
|
77
|
-
requestConsentInfoUpdateWithParameters:parameters
|
78
|
-
completionHandler:^(NSError *_Nullable requestConsentError) {
|
79
|
-
// ...
|
80
|
-
[UMPConsentForm loadAndPresentIfRequiredFromViewController:self.viewController
|
81
|
-
completionHandler:^(NSError *loadAndPresentError) { }]; [self isPrivacyOptionsRequired]; }]; [UMPConsentForm presentPrivacyOptionsFormFromViewController:self.viewController completionHandler:^(NSError * _Nullable formError) {
|
82
|
-
if (formError) {
|
83
|
-
// Handle the error.
|
84
|
-
NSLog(@"Error: %@", formError.localizedDescription);
|
85
|
-
[self fireEvent:@"" event:@"on.getPrivacyOptionsFrom.error" withData:nil];
|
86
|
-
}
|
87
|
-
}];}- (BOOL)isPrivacyOptionsRequired {
|
88
|
-
return UMPConsentInformation.sharedInstance.privacyOptionsRequirementStatus ==
|
89
|
-
UMPPrivacyOptionsRequirementStatusRequired;
|
90
|
-
}- (void)pluginInitialize { isIAB = YES; NSMutableDictionary* result = [[NSMutableDictionary alloc] init];
|
91
|
-
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults]; NSNumber* CmpSdkID = [prefs valueForKey:@"IABTCF_CmpSdkID"];
|
92
|
-
NSString *gdprApplies = [prefs stringForKey:@"IABTCF_gdprApplies"];
|
93
|
-
NSString *PurposeConsents = [prefs stringForKey:@"IABTCF_PurposeConsents"];
|
94
|
-
NSString *TCString = [prefs stringForKey:@"IABTCF_TCString"];
|
95
|
-
result[@"IABTCF_CmpSdkID"] = CmpSdkID;
|
96
|
-
result[@"IABTCF_gdprApplies"] = gdprApplies;
|
97
|
-
result[@"IABTCF_PurposeConsents"] = PurposeConsents;
|
98
|
-
result[@"IABTCF_TCString"] = TCString; NSLog(@"%@", [[NSUserDefaults standardUserDefaults] dictionaryRepresentation]);
|
99
|
-
[prefs synchronize];}- (void)getIabTfc:(CDVInvokedUrlCommand*)command {
|
100
|
-
CDVPluginResult *pluginResult;
|
101
|
-
NSString *callbackId = command.callbackId;
|
102
|
-
if (isIAB == 1) {
|
103
|
-
NSMutableDictionary* result = [[NSMutableDictionary alloc] init];
|
104
|
-
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults]; NSNumber* CmpSdkID = [prefs valueForKey:@"IABTCF_CmpSdkID"];
|
105
|
-
NSString *gdprApplies = [prefs stringForKey:@"IABTCF_gdprApplies"];
|
106
|
-
NSString *PurposeConsents = [prefs stringForKey:@"IABTCF_PurposeConsents"];
|
107
|
-
NSString *TCString = [prefs stringForKey:@"IABTCF_TCString"]; result[@"IABTCF_CmpSdkID"] = CmpSdkID;
|
108
|
-
result[@"IABTCF_gdprApplies"] = gdprApplies;
|
109
|
-
result[@"IABTCF_PurposeConsents"] = PurposeConsents;
|
110
|
-
result[@"IABTCF_TCString"] = TCString; [[NSUserDefaults standardUserDefaults] synchronize]; NSLog(@"%@", [[NSUserDefaults standardUserDefaults] dictionaryRepresentation]);
|
111
|
-
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:result];
|
112
|
-
[self fireEvent:@"" event:@"on.getIabTfc" withData:nil]; } else { pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
|
113
|
-
} [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
114
|
-
}- (void)consentReset:(CDVInvokedUrlCommand*)command {
|
115
|
-
CDVPluginResult *pluginResult;
|
116
|
-
NSString *callbackId = command.callbackId;
|
117
|
-
@try {
|
118
|
-
[[UMPConsentInformation sharedInstance] reset];
|
119
|
-
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
120
|
-
}@catch (NSException *exception) {
|
121
|
-
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:exception.reason];
|
122
|
-
}
|
123
|
-
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
124
|
-
}- (void)setPublisherFirstPartyIDEnabled:(BOOL)enabled{};- (void)globalSettings:(CDVInvokedUrlCommand*)command {
|
125
|
-
CDVPluginResult *pluginResult;
|
126
|
-
NSString *callbackId = command.callbackId;
|
127
|
-
BOOL setAppMuted = [[command argumentAtIndex:0] boolValue];
|
128
|
-
float setAppVolume = [[command argumentAtIndex:1] floatValue];
|
129
|
-
BOOL publisherFirstPartyIdEnabled = [[command argumentAtIndex:3] boolValue];
|
130
|
-
NSString* npa = [command.arguments objectAtIndex:2];
|
131
|
-
BOOL enableCollapsible = [[command argumentAtIndex:3] boolValue];
|
132
|
-
BOOL responseInfo = [[command argumentAtIndex:4] boolValue];
|
133
|
-
@try {
|
134
|
-
GADMobileAds.sharedInstance.applicationVolume = setAppVolume;
|
135
|
-
GADMobileAds.sharedInstance.applicationMuted = setAppMuted;
|
136
|
-
[self setPublisherFirstPartyIDEnabled:publisherFirstPartyIdEnabled];
|
137
|
-
Npa = npa;
|
138
|
-
EnableCollapsible = enableCollapsible;
|
139
|
-
ResponseInfo = responseInfo;
|
140
|
-
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
141
|
-
}@catch (NSException *exception) {
|
142
|
-
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:exception.reason];
|
143
|
-
}
|
144
|
-
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
145
|
-
}- (void)targeting:(CDVInvokedUrlCommand*)command {
|
146
|
-
CDVPluginResult *pluginResult;
|
147
|
-
NSString *callbackId = command.callbackId;
|
148
|
-
NSNumber *childDirectedTreatment = [command argumentAtIndex:0];
|
149
|
-
NSNumber *underAgeOfConsent = [command argumentAtIndex:1];
|
150
|
-
NSString *contentRating = [command argumentAtIndex:2];
|
151
|
-
@try {
|
152
|
-
GADRequestConfiguration *requestConfiguration = GADMobileAds.sharedInstance.requestConfiguration;
|
153
|
-
requestConfiguration.tagForChildDirectedTreatment = childDirectedTreatment;
|
154
|
-
requestConfiguration.tagForUnderAgeOfConsent = underAgeOfConsent;
|
155
|
-
requestConfiguration.maxAdContentRating = contentRating;
|
156
|
-
UnderAgeOfConsent = underAgeOfConsent;
|
157
|
-
}@catch (NSException *exception) {
|
158
|
-
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:exception.reason];
|
159
|
-
} [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];}- (GADAdSize)__AdSizeFromString:(NSString *)size
|
160
|
-
{
|
161
|
-
if ([size isEqualToString:@"ANCHORED"]) {
|
162
|
-
return GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth(adWidth);
|
163
|
-
} else if ([size isEqualToString:@"IN_LINE"]) {
|
164
|
-
return GADCurrentOrientationInlineAdaptiveBannerAdSizeWithWidth(adWidth);
|
165
|
-
} else if ([size isEqualToString:@"BANNER"]) {
|
166
|
-
return GADAdSizeBanner;
|
167
|
-
} else if ([size isEqualToString:@"LARGE_BANNER"]) {
|
168
|
-
return GADAdSizeLargeBanner;
|
169
|
-
} else if ([size isEqualToString:@"FULL_BANNER"]) {
|
170
|
-
return GADAdSizeFullBanner;
|
171
|
-
} else if ([size isEqualToString:@"LEADERBOARD"]) {
|
172
|
-
return GADAdSizeLeaderboard;
|
173
|
-
} else {
|
174
|
-
return GADAdSizeBanner;
|
39
|
+
BOOL UnderAgeOfConsent
|
40
|
+
= NO;
|
41
|
+
BOOL isPrivacyOptions
|
42
|
+
= NO;
|
43
|
+
BOOL isDebugGeography
|
44
|
+
= NO;
|
45
|
+
- (void)initialize:
|
46
|
+
(CDVInvokedUrlCommand
|
47
|
+
*)command
|
48
|
+
{
|
49
|
+
|
50
|
+
GADMobileAds *ads =
|
51
|
+
[GADMobileAds
|
52
|
+
sharedInstance];
|
53
|
+
[ads startWithCompletionHandler:^(
|
54
|
+
GADInitializationStatus
|
55
|
+
*status) {
|
56
|
+
NSDictionary *
|
57
|
+
adapterStatuses
|
58
|
+
= [status
|
59
|
+
adapterStatusesByClassName];
|
60
|
+
for (
|
61
|
+
NSString *adapter in
|
62
|
+
adapterStatuses)
|
63
|
+
{
|
64
|
+
GADAdapterStatus
|
65
|
+
*adapterStatus
|
66
|
+
= adapterStatuses
|
67
|
+
[adapter];
|
68
|
+
NSLog (
|
69
|
+
@"Adapter "
|
70
|
+
@"Name: %@, "
|
71
|
+
@"Descriptio"
|
72
|
+
@"n: %@, "
|
73
|
+
@"Latency: "
|
74
|
+
@"%f",
|
75
|
+
adapter,
|
76
|
+
adapterStatus
|
77
|
+
.description,
|
78
|
+
adapterStatus
|
79
|
+
.latency);
|
175
80
|
}
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
81
|
+
[self
|
82
|
+
fireEvent:@""
|
83
|
+
event:
|
84
|
+
@"on."
|
85
|
+
@"sdkI"
|
86
|
+
@"niti"
|
87
|
+
@"aliz"
|
88
|
+
@"atio"
|
89
|
+
@"n"
|
90
|
+
withData:nil];
|
91
|
+
}];
|
92
|
+
}
|
93
|
+
- (void)requestIDFA:
|
94
|
+
(CDVInvokedUrlCommand
|
95
|
+
*)command
|
96
|
+
{
|
97
|
+
CDVPluginResult
|
98
|
+
*pluginResult;
|
99
|
+
NSString *callbackId
|
100
|
+
= command
|
101
|
+
.callbackId;
|
102
|
+
if (@available (
|
103
|
+
iOS 14, *))
|
104
|
+
{
|
105
|
+
dispatch_async (dispatch_get_main_queue (), ^{
|
106
|
+
[ATTrackingManager
|
107
|
+
requestTrackingAuthorizationWithCompletionHandler:^(
|
108
|
+
ATTrackingManagerAuthorizationStatus
|
109
|
+
status) {
|
110
|
+
if (status
|
111
|
+
== ATTrackingManagerAuthorizationStatusDenied)
|
112
|
+
{
|
113
|
+
idfaStatus
|
114
|
+
= ATTrackingManagerAuthorizationStatusDenied;
|
115
|
+
}
|
116
|
+
else if (
|
117
|
+
status
|
118
|
+
== ATTrackingManagerAuthorizationStatusAuthorized)
|
119
|
+
{
|
120
|
+
idfaStatus
|
121
|
+
= ATTrackingManagerAuthorizationStatusAuthorized;
|
122
|
+
}
|
123
|
+
else if (
|
124
|
+
status
|
125
|
+
== ATTrackingManagerAuthorizationStatusRestricted)
|
126
|
+
{
|
127
|
+
idfaStatus
|
128
|
+
= ATTrackingManagerAuthorizationStatusRestricted;
|
129
|
+
}
|
130
|
+
else if (
|
131
|
+
status
|
132
|
+
== ATTrackingManagerAuthorizationStatusNotDetermined)
|
133
|
+
{
|
134
|
+
idfaStatus
|
135
|
+
= ATTrackingManagerAuthorizationStatusNotDetermined;
|
136
|
+
}
|
137
|
+
}];
|
138
|
+
});
|
139
|
+
[self
|
140
|
+
fireEvent:@""
|
141
|
+
event:
|
142
|
+
@"on."
|
143
|
+
@"getI"
|
144
|
+
@"DFA."
|
145
|
+
@"stat"
|
146
|
+
@"us"
|
147
|
+
withData:nil];
|
148
|
+
pluginResult = [CDVPluginResult
|
149
|
+
resultWithStatus:
|
150
|
+
CDVCommandStatus_OK
|
151
|
+
messageAsInt:
|
152
|
+
idfaStatus];
|
153
|
+
}
|
154
|
+
else
|
155
|
+
{
|
156
|
+
[self
|
157
|
+
fireEvent:@""
|
158
|
+
event:
|
159
|
+
@"on."
|
160
|
+
@"getI"
|
161
|
+
@"DFA."
|
162
|
+
@"erro"
|
163
|
+
@"r"
|
164
|
+
withData:nil];
|
165
|
+
pluginResult = [CDVPluginResult
|
166
|
+
resultWithStatus:
|
167
|
+
CDVCommandStatus_ERROR];
|
168
|
+
}
|
169
|
+
[self.commandDelegate
|
170
|
+
sendPluginResult:
|
171
|
+
pluginResult
|
172
|
+
callbackId:
|
173
|
+
callbackId];
|
174
|
+
}
|
175
|
+
|
176
|
+
- (void)
|
177
|
+
getConsentRequest:
|
178
|
+
(CDVInvokedUrlCommand
|
179
|
+
*)command
|
180
|
+
{
|
181
|
+
__block
|
182
|
+
CDVPluginResult *
|
183
|
+
pluginResult;
|
184
|
+
NSString *callbackId
|
185
|
+
= command
|
186
|
+
.callbackId;
|
187
|
+
NSString *deviceId = [self
|
188
|
+
__getAdMobDeviceId];
|
189
|
+
UMPRequestParameters
|
190
|
+
*parameters
|
191
|
+
= [[UMPRequestParameters
|
192
|
+
alloc] init];
|
193
|
+
|
194
|
+
if (isDebugGeography
|
195
|
+
== YES)
|
196
|
+
{
|
197
|
+
UMPDebugSettings
|
198
|
+
*debugSettings
|
199
|
+
= [[UMPDebugSettings
|
200
|
+
alloc]
|
201
|
+
init];
|
202
|
+
parameters
|
203
|
+
.debugSettings
|
204
|
+
= debugSettings;
|
205
|
+
debugSettings
|
206
|
+
.geography
|
207
|
+
= UMPDebugGeographyEEA;
|
208
|
+
debugSettings
|
209
|
+
.testDeviceIdentifiers
|
210
|
+
= @[
|
211
|
+
deviceId
|
212
|
+
];
|
213
|
+
}
|
214
|
+
parameters
|
215
|
+
.tagForUnderAgeOfConsent
|
216
|
+
= UnderAgeOfConsent;
|
217
|
+
// NSLog(@"tag For
|
218
|
+
// Under Age Of
|
219
|
+
// Consent %s",
|
220
|
+
// UnderAgeOfConsent
|
221
|
+
// ? "true" :
|
222
|
+
// "false");
|
223
|
+
dispatch_async (dispatch_get_main_queue (),
|
224
|
+
^{
|
225
|
+
[UMPConsentInformation
|
226
|
+
.sharedInstance
|
227
|
+
requestConsentInfoUpdateWithParameters:
|
228
|
+
parameters
|
229
|
+
completionHandler:^(
|
230
|
+
NSError
|
231
|
+
*_Nullable requestConsentError) {
|
232
|
+
if (requestConsentError)
|
233
|
+
{
|
234
|
+
NSLog (
|
235
|
+
@"request Consent Error: %@",
|
236
|
+
requestConsentError
|
237
|
+
.localizedDescription);
|
238
|
+
|
239
|
+
pluginResult = [CDVPluginResult
|
240
|
+
resultWithStatus:
|
241
|
+
CDVCommandStatus_ERROR
|
242
|
+
messageAsString:
|
243
|
+
requestConsentError
|
244
|
+
.description];
|
245
|
+
|
246
|
+
return;
|
247
|
+
}
|
248
|
+
[self
|
249
|
+
readStatus:
|
250
|
+
command];
|
251
|
+
[UMPConsentForm loadWithCompletionHandler:^(
|
252
|
+
UMPConsentForm
|
253
|
+
*form,
|
254
|
+
NSError
|
255
|
+
*loadError) {
|
256
|
+
if (loadError)
|
257
|
+
{
|
258
|
+
pluginResult = [CDVPluginResult
|
259
|
+
resultWithStatus:
|
260
|
+
CDVCommandStatus_ERROR
|
261
|
+
messageAsString:
|
262
|
+
loadError
|
263
|
+
.description];
|
264
|
+
NSLog (
|
265
|
+
@"load Error: %@",
|
266
|
+
loadError
|
267
|
+
.localizedDescription);
|
268
|
+
}
|
269
|
+
else
|
270
|
+
{
|
271
|
+
[form
|
272
|
+
presentFromViewController:
|
273
|
+
[UIApplication
|
274
|
+
sharedApplication]
|
275
|
+
.delegate
|
276
|
+
.window
|
277
|
+
.rootViewController
|
278
|
+
completionHandler:
|
279
|
+
^(NSError
|
280
|
+
*_Nullable dismissError) {
|
281
|
+
if (dismissError)
|
282
|
+
{
|
283
|
+
NSLog (
|
284
|
+
@"dismiss Error: %@",
|
285
|
+
dismissError
|
286
|
+
.localizedDescription);
|
287
|
+
pluginResult = [CDVPluginResult
|
288
|
+
resultWithStatus:
|
289
|
+
CDVCommandStatus_ERROR
|
290
|
+
messageAsString:
|
291
|
+
dismissError
|
292
|
+
.description];
|
293
|
+
}
|
294
|
+
else
|
295
|
+
{
|
296
|
+
NSLog (
|
297
|
+
@"UMP ConsentInformation: %@",
|
298
|
+
UMPConsentInformation
|
299
|
+
.description);
|
300
|
+
pluginResult = [CDVPluginResult
|
301
|
+
resultWithStatus:
|
302
|
+
CDVCommandStatus_ERROR
|
303
|
+
messageAsString:
|
304
|
+
UMPConsentInformation
|
305
|
+
.description];
|
306
|
+
}
|
307
|
+
}];
|
308
|
+
}
|
309
|
+
}];
|
310
|
+
|
311
|
+
[self
|
312
|
+
fireEvent:
|
313
|
+
@""
|
314
|
+
event:
|
315
|
+
@"on.get.from.status"
|
316
|
+
withData:
|
317
|
+
nil];
|
318
|
+
}];
|
319
|
+
|
320
|
+
[self.commandDelegate
|
321
|
+
sendPluginResult:
|
322
|
+
pluginResult
|
323
|
+
callbackId:
|
324
|
+
callbackId];
|
325
|
+
});
|
326
|
+
}
|
327
|
+
|
328
|
+
- (void)
|
329
|
+
showPrivacyOptionsForm:
|
330
|
+
(CDVInvokedUrlCommand
|
331
|
+
*)command
|
332
|
+
{
|
333
|
+
NSString *deviceId = [self
|
334
|
+
__getAdMobDeviceId];
|
335
|
+
UMPRequestParameters
|
336
|
+
*parameters
|
337
|
+
= [[UMPRequestParameters
|
338
|
+
alloc] init];
|
339
|
+
if (isDebugGeography
|
340
|
+
== YES)
|
341
|
+
{
|
342
|
+
UMPDebugSettings
|
343
|
+
*debugSettings
|
344
|
+
= [[UMPDebugSettings
|
345
|
+
alloc]
|
346
|
+
init];
|
347
|
+
parameters
|
348
|
+
.debugSettings
|
349
|
+
= debugSettings;
|
350
|
+
debugSettings
|
351
|
+
.geography
|
352
|
+
= UMPDebugGeographyEEA;
|
353
|
+
debugSettings
|
354
|
+
.testDeviceIdentifiers
|
355
|
+
= @[
|
356
|
+
deviceId
|
357
|
+
];
|
358
|
+
}
|
359
|
+
parameters
|
360
|
+
.tagForUnderAgeOfConsent
|
361
|
+
= UnderAgeOfConsent;
|
362
|
+
dispatch_async (dispatch_get_main_queue (),
|
363
|
+
^{
|
364
|
+
[UMPConsentInformation
|
365
|
+
.sharedInstance
|
366
|
+
requestConsentInfoUpdateWithParameters:
|
367
|
+
parameters
|
368
|
+
completionHandler:
|
369
|
+
^(NSError
|
370
|
+
*_Nullable requestConsentError) {
|
371
|
+
[UMPConsentForm
|
372
|
+
loadAndPresentIfRequiredFromViewController:
|
373
|
+
self.viewController
|
374
|
+
completionHandler:^(
|
375
|
+
NSError
|
376
|
+
*loadAndPresentError) {
|
377
|
+
CDVPluginResult
|
378
|
+
*pluginResult
|
379
|
+
= [CDVPluginResult
|
380
|
+
resultWithStatus:
|
381
|
+
CDVCommandStatus_ERROR
|
382
|
+
messageAsString:
|
383
|
+
loadAndPresentError
|
384
|
+
.description];
|
385
|
+
[self.commandDelegate
|
386
|
+
sendPluginResult:
|
387
|
+
pluginResult
|
388
|
+
callbackId:
|
389
|
+
command
|
390
|
+
.callbackId];
|
391
|
+
}];
|
392
|
+
|
393
|
+
[self
|
394
|
+
isPrivacyOptionsRequired];
|
395
|
+
isPrivacyOptions
|
396
|
+
= YES;
|
397
|
+
[self
|
398
|
+
privacyOptionsFormShow:
|
399
|
+
command];
|
400
|
+
}];
|
401
|
+
});
|
402
|
+
}
|
403
|
+
|
404
|
+
- (void)
|
405
|
+
privacyOptionsFormShow:
|
406
|
+
(CDVInvokedUrlCommand
|
407
|
+
*)command
|
408
|
+
{
|
409
|
+
|
410
|
+
[self.commandDelegate runInBackground:
|
411
|
+
^{
|
412
|
+
if (isPrivacyOptions
|
413
|
+
== YES)
|
414
|
+
{
|
415
|
+
dispatch_async (dispatch_get_main_queue (),
|
416
|
+
^{
|
417
|
+
[UMPConsentForm presentPrivacyOptionsFormFromViewController:
|
418
|
+
self.viewController
|
419
|
+
completionHandler:
|
420
|
+
^(NSError
|
421
|
+
*_Nullable formError) {
|
422
|
+
if (formError)
|
423
|
+
{
|
424
|
+
// Handle the error.
|
425
|
+
CDVPluginResult
|
426
|
+
*pluginResult
|
427
|
+
= [CDVPluginResult
|
428
|
+
resultWithStatus:
|
429
|
+
CDVCommandStatus_ERROR
|
430
|
+
messageAsString:
|
431
|
+
formError
|
432
|
+
.description];
|
433
|
+
[self.commandDelegate
|
434
|
+
sendPluginResult:
|
435
|
+
pluginResult
|
436
|
+
callbackId:
|
437
|
+
command
|
438
|
+
.callbackId];
|
439
|
+
}
|
440
|
+
}];
|
441
|
+
});
|
442
|
+
}
|
443
|
+
}];
|
444
|
+
}
|
445
|
+
|
446
|
+
- (void)readStatus:
|
447
|
+
(CDVInvokedUrlCommand
|
448
|
+
*)command
|
449
|
+
{
|
450
|
+
[self.commandDelegate runInBackground:^{
|
451
|
+
Consent_Status
|
452
|
+
= (int)UMPConsentInformation
|
453
|
+
.sharedInstance
|
454
|
+
.consentStatus;
|
455
|
+
|
456
|
+
if (Consent_Status
|
457
|
+
== UMPConsentStatusUnknown)
|
458
|
+
{
|
459
|
+
|
460
|
+
Consent_Status
|
461
|
+
= UMPConsentStatusUnknown;
|
180
462
|
}
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
BOOL autoShow = [[command argumentAtIndex:5] boolValue];
|
189
|
-
auto_Show = autoShow;
|
190
|
-
int intValue = [adaptive_Width intValue];
|
191
|
-
adWidth = intValue;
|
192
|
-
Position = position;
|
193
|
-
// float posX = [x floatValue];
|
194
|
-
// float posY = [y floatValue];
|
195
|
-
GADAdSize sizes = [self __AdSizeFromString:size]; // CGPoint origin = CGPointMake(posX,posY);
|
196
|
-
self.bannerView = [[GADBannerView alloc]
|
197
|
-
initWithAdSize:sizes]; GADRequest *request = [GADRequest request];
|
198
|
-
GADExtras *extras = [[GADExtras alloc] init];
|
199
|
-
if (EnableCollapsible){
|
200
|
-
extras.additionalParameters = @{@"collapsible" : collapsible};
|
201
|
-
}
|
202
|
-
extras.additionalParameters = @{@"npa": Npa};
|
203
|
-
[request registerAdNetworkExtras:extras];
|
204
|
-
self.bannerView.adUnitID = adUnitId;
|
205
|
-
self.bannerView.rootViewController = self.viewController;
|
206
|
-
self.bannerView.delegate = self;
|
207
|
-
[self.bannerView loadRequest:request];
|
208
|
-
self.bannerView.hidden = YES;
|
209
|
-
[parentView addSubview:self.bannerView];
|
210
|
-
[parentView bringSubviewToFront:self.bannerView]; pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
211
|
-
} else {
|
212
|
-
NSLog(@"Admob Option invalid for banner");
|
213
|
-
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
|
463
|
+
else if (
|
464
|
+
Consent_Status
|
465
|
+
== UMPConsentStatusRequired)
|
466
|
+
{
|
467
|
+
|
468
|
+
Consent_Status
|
469
|
+
= UMPConsentStatusRequired;
|
214
470
|
}
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
[self fireEvent:@"" event:@"on.banner.failed.show" withData:nil];
|
223
|
-
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
|
471
|
+
else if (
|
472
|
+
Consent_Status
|
473
|
+
== UMPConsentStatusNotRequired)
|
474
|
+
{
|
475
|
+
|
476
|
+
Consent_Status
|
477
|
+
= UMPConsentStatusNotRequired;
|
224
478
|
}
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
relatedBy:NSLayoutRelationEqual
|
233
|
-
toItem:self.viewController.view.safeAreaLayoutGuide
|
234
|
-
attribute:NSLayoutAttributeBottom
|
235
|
-
multiplier:1
|
236
|
-
constant:0 ],
|
237
|
-
[NSLayoutConstraint constraintWithItem:bannerView
|
238
|
-
attribute:NSLayoutAttributeCenterX
|
239
|
-
relatedBy:NSLayoutRelationEqual
|
240
|
-
toItem:self.viewController.view
|
241
|
-
attribute:NSLayoutAttributeCenterX
|
242
|
-
multiplier:1
|
243
|
-
constant:0]
|
244
|
-
]];
|
245
|
-
} else {
|
246
|
-
[self.viewController.view addConstraints:@[
|
247
|
-
[NSLayoutConstraint constraintWithItem:bannerView
|
248
|
-
attribute:NSLayoutAttributeTop
|
249
|
-
relatedBy:NSLayoutRelationEqual
|
250
|
-
toItem:self.viewController.view.safeAreaLayoutGuide
|
251
|
-
attribute:NSLayoutAttributeTop
|
252
|
-
multiplier:1
|
253
|
-
constant:0],
|
254
|
-
[NSLayoutConstraint constraintWithItem:bannerView
|
255
|
-
attribute:NSLayoutAttributeCenterX
|
256
|
-
relatedBy:NSLayoutRelationEqual
|
257
|
-
toItem:self.viewController.view
|
258
|
-
attribute:NSLayoutAttributeCenterX
|
259
|
-
multiplier:1
|
260
|
-
constant:0]
|
261
|
-
]];
|
262
|
-
}}- (void)hideBannerAd:(CDVInvokedUrlCommand*)command {
|
263
|
-
CDVPluginResult *pluginResult;
|
264
|
-
NSString *callbackId = command.callbackId;
|
265
|
-
if(self.bannerView) {
|
266
|
-
self.bannerView.hidden = YES;
|
267
|
-
[self fireEvent:@"" event:@"on.banner.hide" withData:nil];
|
268
|
-
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
269
|
-
} else {
|
270
|
-
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
|
271
|
-
}
|
272
|
-
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
273
|
-
}- (void)removeBannerAd:(CDVInvokedUrlCommand*)command {
|
274
|
-
CDVPluginResult *pluginResult;
|
275
|
-
NSString *callbackId = command.callbackId;
|
276
|
-
if(self.bannerView) {
|
277
|
-
self.bannerView.hidden = YES;
|
278
|
-
[self.bannerView removeFromSuperview];
|
279
|
-
self.bannerView = nil;
|
280
|
-
[self fireEvent:@"" event:@"on.banner.remove" withData:nil];
|
281
|
-
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
282
|
-
} else {
|
283
|
-
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
|
284
|
-
}
|
285
|
-
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];}- (void)loadAppOpenAd:(CDVInvokedUrlCommand *)command {
|
286
|
-
CDVPluginResult *pluginResult;
|
287
|
-
NSString *callbackId = command.callbackId;
|
288
|
-
NSString* adUnitId = [command.arguments objectAtIndex:0];
|
289
|
-
BOOL autoShow = [[command argumentAtIndex:1] boolValue];
|
290
|
-
auto_Show = autoShow;
|
291
|
-
adFormat = 1;
|
292
|
-
self.appOpenAd = nil;
|
293
|
-
if (adFormat == 1){
|
294
|
-
GADRequest *request = [GADRequest request];
|
295
|
-
GADExtras *extras = [[GADExtras alloc] init];
|
296
|
-
extras.additionalParameters = @{@"npa": Npa};
|
297
|
-
[request registerAdNetworkExtras:extras];
|
298
|
-
[GADAppOpenAd loadWithAdUnitID:adUnitId
|
299
|
-
request:request
|
300
|
-
orientation:UIInterfaceOrientationPortrait
|
301
|
-
completionHandler:^(GADAppOpenAd *ad, NSError *error) {
|
302
|
-
if (error) {
|
303
|
-
[self fireEvent:@"" event:@"on.appOpenAd.failed.loaded" withData:nil];
|
304
|
-
NSLog(@"Failed to load App Open Ad ad with error: %@", [error localizedDescription]); return;
|
305
|
-
}
|
306
|
-
self.appOpenAd = ad;
|
307
|
-
self.appOpenAd.fullScreenContentDelegate = self;
|
308
|
-
[self fireEvent:@"" event:@"on.appOpenAd.loaded" withData:nil];
|
309
|
-
if (auto_Show){ if (self.appOpenAd && [self.appOpenAd
|
310
|
-
canPresentFromRootViewController:self.viewController
|
311
|
-
error:nil]) { [self.appOpenAd presentFromRootViewController:self.viewController]; } else {
|
312
|
-
[self fireEvent:@"" event:@"on.appOpenAd.failed.show" withData:nil];
|
313
|
-
}}
|
314
|
-
}]; pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
315
|
-
} [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];}- (void)showAppOpenAd:(CDVInvokedUrlCommand *)command {
|
316
|
-
CDVPluginResult *pluginResult;
|
317
|
-
NSString *callbackId = command.callbackId;
|
318
|
-
if (self.appOpenAd && [self.appOpenAd
|
319
|
-
canPresentFromRootViewController:self.viewController
|
320
|
-
error:nil]) { [self.appOpenAd presentFromRootViewController:self.viewController]; pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; } else { pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
|
321
|
-
[self fireEvent:@"" event:@"on.appOpenAd.failed.show" withData:nil];
|
322
|
-
}
|
323
|
-
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
324
|
-
}- (void)loadInterstitialAd:(CDVInvokedUrlCommand *)command {
|
325
|
-
CDVPluginResult *pluginResult;
|
326
|
-
NSString *callbackId = command.callbackId;
|
327
|
-
NSString* adUnitId = [command.arguments objectAtIndex:0];
|
328
|
-
BOOL autoShow = [[command argumentAtIndex:1] boolValue];
|
329
|
-
auto_Show = autoShow;
|
330
|
-
adFormat = 2;
|
331
|
-
if (adFormat == 2){
|
332
|
-
GADRequest *request = [GADRequest request];
|
333
|
-
[GADInterstitialAd
|
334
|
-
loadWithAdUnitID:adUnitId
|
335
|
-
request:request
|
336
|
-
completionHandler:^(GADInterstitialAd *ad, NSError *error) {
|
337
|
-
if (error) { NSLog(@"Failed to load interstitial ad with error: %@", [error localizedDescription]);
|
338
|
-
// [self fireEvent:@"" event:@"on.interstitial.failed.load" withData:nil]; return;
|
339
|
-
} self.interstitial = ad;
|
340
|
-
self.interstitial.fullScreenContentDelegate = self;
|
341
|
-
[self fireEvent:@"" event:@"on.interstitial.loaded" withData:nil]; if (auto_Show){ if (self.interstitial && [self.interstitial
|
342
|
-
canPresentFromRootViewController:self.viewController error:nil]) { [self.interstitial presentFromRootViewController:self.viewController]; } else { [self fireEvent:@"" event:@"on.interstitial.failed.show" withData:nil];
|
343
|
-
} } }];
|
344
|
-
} pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
345
|
-
}- (void)showInterstitialAd:(CDVInvokedUrlCommand *)command {
|
346
|
-
CDVPluginResult *pluginResult;
|
347
|
-
NSString *callbackId = command.callbackId;
|
348
|
-
if (self.interstitial && [self.interstitial
|
349
|
-
canPresentFromRootViewController:self.viewController error:nil]) { [self.interstitial presentFromRootViewController:self.viewController];
|
350
|
-
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
351
|
-
} else {
|
352
|
-
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
|
353
|
-
[self fireEvent:@"" event:@"on.interstitial.failed.show" withData:nil];
|
354
|
-
} [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
355
|
-
}- (void)loadRewardedInterstitialAd:(CDVInvokedUrlCommand*)command { CDVPluginResult *pluginResult;
|
356
|
-
NSString *callbackId = command.callbackId;
|
357
|
-
NSString* adUnitId = [command.arguments objectAtIndex:0];
|
358
|
-
BOOL autoShow = [[command argumentAtIndex:1] boolValue];
|
359
|
-
auto_Show = autoShow;
|
360
|
-
adFormat = 4;
|
361
|
-
if (adFormat == 4){ GADRequest *request = [GADRequest request];
|
362
|
-
[GADRewardedInterstitialAd
|
363
|
-
loadWithAdUnitID:adUnitId
|
364
|
-
request:request
|
365
|
-
completionHandler:^(GADRewardedInterstitialAd *ad, NSError *error) {
|
366
|
-
if (error) {
|
367
|
-
NSLog(@"Rewarded ad failed to load with error: %@", [error localizedDescription]);
|
368
|
-
return;
|
369
|
-
}
|
370
|
-
self.rewardedInterstitialAd = ad; isAdSkip = 1;
|
371
|
-
NSLog(@"Rewarded ad loaded.");
|
372
|
-
self.rewardedInterstitialAd.fullScreenContentDelegate = self;
|
373
|
-
[self fireEvent:@"" event:@"on.rewardedInt.loaded" withData:nil]; if (auto_Show){ if (self.rewardedInterstitialAd && [self.rewardedInterstitialAd canPresentFromRootViewController:self.viewController error:nil]) { [self.rewardedInterstitialAd presentFromRootViewController:self.viewController
|
374
|
-
userDidEarnRewardHandler:^{
|
375
|
-
GADAdReward *reward =
|
376
|
-
self.rewardedInterstitialAd.adReward;
|
377
|
-
[self fireEvent:@"" event:@"on.rewardedInt.userEarnedReward" withData:nil];
|
378
|
-
isAdSkip = 2;
|
379
|
-
NSString *rewardMessage = [NSString stringWithFormat:@"Reward received with "
|
380
|
-
@"currency %@ , amount %ld",
|
381
|
-
reward.type, [reward.amount longValue]];
|
382
|
-
NSLog(@"%@", rewardMessage); }]; } else { [self fireEvent:@"" event:@"on.rewardedInt.failed.show" withData:nil];
|
383
|
-
} } }];
|
384
|
-
}
|
385
|
-
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
386
|
-
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
387
|
-
}-(void)showRewardedInterstitialAd:(CDVInvokedUrlCommand *)command {
|
388
|
-
CDVPluginResult *pluginResult;
|
389
|
-
NSString *callbackId = command.callbackId;
|
390
|
-
if (self.rewardedInterstitialAd && [self.rewardedInterstitialAd canPresentFromRootViewController:self.viewController error:nil]) { [self.rewardedInterstitialAd presentFromRootViewController:self.viewController
|
391
|
-
userDidEarnRewardHandler:^{
|
392
|
-
GADAdReward *reward =
|
393
|
-
self.rewardedInterstitialAd.adReward;
|
394
|
-
[self fireEvent:@"" event:@"on.rewardedInt.userEarnedReward" withData:nil];
|
395
|
-
isAdSkip = 2;
|
396
|
-
NSString *rewardMessage = [NSString stringWithFormat:@"Reward received with "
|
397
|
-
@"currency %@ , amount %ld",
|
398
|
-
reward.type, [reward.amount longValue]];
|
399
|
-
NSLog(@"%@", rewardMessage); }]; pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; } else {
|
400
|
-
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
|
401
|
-
[self fireEvent:@"" event:@"on.rewardedInt.failed.show" withData:nil];
|
402
|
-
} [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
403
|
-
}- (void)loadRewardedAd:(CDVInvokedUrlCommand*)command { CDVPluginResult *pluginResult;
|
404
|
-
NSString *callbackId = command.callbackId;
|
405
|
-
NSString* adUnitId = [command.arguments objectAtIndex:0];
|
406
|
-
BOOL autoShow = [[command argumentAtIndex:1] boolValue];
|
407
|
-
auto_Show = autoShow;
|
408
|
-
adFormat = 3;
|
409
|
-
if (adFormat == 3){
|
410
|
-
GADRequest *request = [GADRequest request];
|
411
|
-
[GADRewardedAd
|
412
|
-
loadWithAdUnitID:adUnitId
|
413
|
-
request:request
|
414
|
-
completionHandler:^(GADRewardedAd *ad, NSError *error) {
|
415
|
-
if (error) {
|
416
|
-
NSLog(@"Rewarded ad failed to load with error: %@", [error localizedDescription]);
|
417
|
-
return;
|
418
|
-
}
|
419
|
-
self.rewardedAd = ad;
|
420
|
-
NSLog(@"Rewarded ad loaded.");
|
421
|
-
isAdSkip = 0;
|
422
|
-
self.rewardedAd.fullScreenContentDelegate = self;
|
423
|
-
[self fireEvent:@"" event:@"on.rewarded.loaded" withData:nil]; if (auto_Show){ if (self.rewardedAd && [self.rewardedAd canPresentFromRootViewController:self.viewController error:nil]) { [self.rewardedAd presentFromRootViewController:self.viewController
|
424
|
-
userDidEarnRewardHandler:^{
|
425
|
-
GADAdReward *reward =
|
426
|
-
self.rewardedAd.adReward;
|
427
|
-
[self fireEvent:@"" event:@"on.reward.userEarnedReward" withData:nil];
|
428
|
-
isAdSkip = 2;
|
429
|
-
NSString *rewardMessage = [NSString stringWithFormat:@"Reward received with currency %@ , amount %lf", reward.type, [reward.amount doubleValue]];
|
430
|
-
NSLog(@"%@", rewardMessage); }]; } else { [self fireEvent:@"" event:@"on.rewarded.failed.show" withData:nil];
|
431
|
-
} } }];
|
432
|
-
}
|
433
|
-
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
434
|
-
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
435
|
-
}-(void)showRewardedAd:(CDVInvokedUrlCommand *)command {
|
436
|
-
CDVPluginResult *pluginResult;
|
437
|
-
NSString *callbackId = command.callbackId;
|
438
|
-
if (self.rewardedAd && [self.rewardedAd canPresentFromRootViewController:self.viewController error:nil]) { [self.rewardedAd presentFromRootViewController:self.viewController
|
439
|
-
userDidEarnRewardHandler:^{
|
440
|
-
GADAdReward *reward =
|
441
|
-
self.rewardedAd.adReward;
|
442
|
-
[self fireEvent:@"" event:@"on.reward.userEarnedReward" withData:nil];
|
443
|
-
isAdSkip = 2;
|
444
|
-
NSString *rewardMessage = [NSString stringWithFormat:@"Reward received with currency %@ , amount %lf", reward.type, [reward.amount doubleValue]];
|
445
|
-
NSLog(@"%@", rewardMessage); }]; pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; } else {
|
446
|
-
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
|
447
|
-
[self fireEvent:@"" event:@"on.rewarded.failed.show" withData:nil];
|
448
|
-
} [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
449
|
-
}- (void) fireEvent:(NSString *)obj event:(NSString *)eventName withData:(NSString *)jsonStr {
|
450
|
-
NSString* js;
|
451
|
-
if(obj && [obj isEqualToString:@"window"]) {
|
452
|
-
js = [NSString stringWithFormat:@"var evt=document.createEvent(\"UIEvents\");evt.initUIEvent(\"%@\",true,false,window,0);window.dispatchEvent(evt);", eventName];
|
453
|
-
} else if(jsonStr && [jsonStr length]>0) {
|
454
|
-
js = [NSString stringWithFormat:@"javascript:cordova.fireDocumentEvent('%@',%@);", eventName, jsonStr];
|
455
|
-
} else {
|
456
|
-
js = [NSString stringWithFormat:@"javascript:cordova.fireDocumentEvent('%@');", eventName];
|
457
|
-
}
|
458
|
-
[self.commandDelegate evalJs:js];
|
459
|
-
}
|
460
|
-
#pragma mark GADBannerViewDelegate implementation
|
461
|
-
-(void)bannerViewDidReceiveAd:(GADBannerView *)bannerView {
|
462
|
-
[self fireEvent:@"" event:@"on.banner.load" withData:nil];
|
463
|
-
NSLog(@"bannerViewDidReceiveAd");
|
464
|
-
if (auto_Show){
|
465
|
-
if(self.bannerView) {
|
466
|
-
[self addBannerViewToView:command];
|
467
|
-
self.bannerView.hidden = NO;
|
468
|
-
}
|
469
|
-
} else { [self fireEvent:@"" event:@"on.banner.failed.show" withData:nil];
|
470
|
-
}}- (void)bannerView:(GADBannerView *)bannerView didFailToReceiveAdWithError:(NSError *)error {
|
471
|
-
[self fireEvent:@"" event:@"on.banner.failed.load" withData:nil];
|
472
|
-
NSLog(@"bannerView:didFailToReceiveAdWithError: %@", [error localizedDescription]);
|
473
|
-
}- (void)bannerViewDidRecordImpression:(GADBannerView *)bannerView {
|
474
|
-
[self fireEvent:@"" event:@"on.banner.impression" withData:nil];
|
475
|
-
NSLog(@"bannerViewDidRecordImpression");
|
476
|
-
}- (void)bannerViewWillPresentScreen:(GADBannerView *)bannerView {
|
477
|
-
[self fireEvent:@"" event:@"on.banner.open" withData:nil];
|
478
|
-
NSLog(@"bannerViewWillPresentScreen");
|
479
|
-
}- (void)bannerViewWillDismissScreen:(GADBannerView *)bannerView {
|
480
|
-
[self fireEvent:@"" event:@"on.banner.close" withData:nil];
|
481
|
-
NSLog(@"bannerViewWillDismissScreen");
|
482
|
-
}- (void)bannerViewDidDismissScreen:(GADBannerView *)bannerView {
|
483
|
-
[self fireEvent:@"" event:@"on.banner.did.dismiss" withData:nil];
|
484
|
-
NSLog(@"bannerViewDidDismissScreen");
|
479
|
+
else if (
|
480
|
+
Consent_Status
|
481
|
+
== UMPConsentStatusObtained)
|
482
|
+
{
|
483
|
+
|
484
|
+
Consent_Status
|
485
|
+
= UMPConsentStatusObtained;
|
485
486
|
}
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
487
|
+
|
488
|
+
NSLog (
|
489
|
+
@"The Consent "
|
490
|
+
@"Status %i",
|
491
|
+
Consent_Status);
|
492
|
+
CDVPluginResult
|
493
|
+
*pluginResult
|
494
|
+
= [CDVPluginResult
|
495
|
+
resultWithStatus:
|
496
|
+
CDVCommandStatus_OK
|
497
|
+
messageAsInt:
|
498
|
+
Consent_Status];
|
499
|
+
[self.commandDelegate
|
500
|
+
sendPluginResult:
|
501
|
+
pluginResult
|
502
|
+
callbackId:
|
503
|
+
command
|
504
|
+
.callbackId];
|
505
|
+
}];
|
506
|
+
}
|
507
|
+
|
508
|
+
- (BOOL)
|
509
|
+
isPrivacyOptionsRequired
|
510
|
+
{
|
511
|
+
return UMPConsentInformation
|
512
|
+
.sharedInstance
|
513
|
+
.privacyOptionsRequirementStatus
|
514
|
+
== UMPPrivacyOptionsRequirementStatusRequired;
|
515
|
+
}
|
516
|
+
|
517
|
+
- (void)
|
518
|
+
pluginInitialize
|
519
|
+
{
|
520
|
+
isIAB = YES;
|
521
|
+
NSMutableDictionary
|
522
|
+
*result
|
523
|
+
= [[NSMutableDictionary
|
524
|
+
alloc] init];
|
525
|
+
NSUserDefaults *prefs
|
526
|
+
= [NSUserDefaults
|
527
|
+
standardUserDefaults];
|
528
|
+
NSNumber *CmpSdkID =
|
529
|
+
[prefs
|
530
|
+
valueForKey:
|
531
|
+
@"IABTCF"
|
532
|
+
@"_CmpSd"
|
533
|
+
@"kID"];
|
534
|
+
NSString *gdprApplies
|
535
|
+
= [prefs
|
536
|
+
stringForKey:
|
537
|
+
@"IABTCF"
|
538
|
+
@"_gdprA"
|
539
|
+
@"pplie"
|
540
|
+
@"s"];
|
541
|
+
NSString
|
542
|
+
*PurposeConsents
|
543
|
+
= [prefs
|
544
|
+
stringForKey:
|
545
|
+
@"IABTCF"
|
546
|
+
@"_Purpo"
|
547
|
+
@"seCons"
|
548
|
+
@"ents"];
|
549
|
+
NSString *TCString =
|
550
|
+
[prefs
|
551
|
+
stringForKey:
|
552
|
+
@"IABTCF"
|
553
|
+
@"_TCStr"
|
554
|
+
@"ing"];
|
555
|
+
result[@"IABTCF_"
|
556
|
+
@"CmpSdkID"]
|
557
|
+
= CmpSdkID;
|
558
|
+
result
|
559
|
+
[@"IABTCF_"
|
560
|
+
@"gdprApplies"]
|
561
|
+
= gdprApplies;
|
562
|
+
result[@"IABTCF_"
|
563
|
+
@"PurposeCons"
|
564
|
+
@"ents"]
|
565
|
+
= PurposeConsents;
|
566
|
+
result[@"IABTCF_"
|
567
|
+
@"TCString"]
|
568
|
+
= TCString;
|
569
|
+
// NSLog(@"%@",
|
570
|
+
// [[NSUserDefaults
|
571
|
+
// standardUserDefaults]
|
572
|
+
// dictionaryRepresentation]);
|
573
|
+
[prefs synchronize];
|
574
|
+
}
|
575
|
+
- (void)getIabTfc:
|
576
|
+
(CDVInvokedUrlCommand
|
577
|
+
*)command
|
578
|
+
{
|
579
|
+
CDVPluginResult
|
580
|
+
*pluginResult;
|
581
|
+
NSString *callbackId
|
582
|
+
= command
|
583
|
+
.callbackId;
|
584
|
+
if (isIAB == 1)
|
585
|
+
{
|
586
|
+
NSMutableDictionary
|
587
|
+
*result
|
588
|
+
= [[NSMutableDictionary
|
589
|
+
alloc]
|
590
|
+
init];
|
591
|
+
NSUserDefaults
|
592
|
+
*prefs
|
593
|
+
= [NSUserDefaults
|
594
|
+
standardUserDefaults];
|
595
|
+
NSNumber *CmpSdkID
|
596
|
+
= [prefs
|
597
|
+
valueForKey:
|
598
|
+
@"IABT"
|
599
|
+
@"CF_"
|
600
|
+
@"CmpS"
|
601
|
+
@"dkI"
|
602
|
+
@"D"];
|
603
|
+
NSString
|
604
|
+
*gdprApplies
|
605
|
+
= [prefs
|
606
|
+
stringForKey:
|
607
|
+
@"IABT"
|
608
|
+
@"CF_"
|
609
|
+
@"gdpr"
|
610
|
+
@"Appl"
|
611
|
+
@"ie"
|
612
|
+
@"s"];
|
613
|
+
NSString *
|
614
|
+
PurposeConsents
|
615
|
+
= [prefs
|
616
|
+
stringForKey:
|
617
|
+
@"IABT"
|
618
|
+
@"CF_"
|
619
|
+
@"Purp"
|
620
|
+
@"oseC"
|
621
|
+
@"onse"
|
622
|
+
@"nt"
|
623
|
+
@"s"];
|
624
|
+
NSString *TCString
|
625
|
+
= [prefs
|
626
|
+
stringForKey:
|
627
|
+
@"IABT"
|
628
|
+
@"CF_"
|
629
|
+
@"TCSt"
|
630
|
+
@"rin"
|
631
|
+
@"g"];
|
632
|
+
result[@"IABTCF_"
|
633
|
+
@"CmpSdkID"]
|
634
|
+
= CmpSdkID;
|
635
|
+
result[@"IABTCF_"
|
636
|
+
@"gdprAppli"
|
637
|
+
@"es"]
|
638
|
+
= gdprApplies;
|
639
|
+
result[@"IABTCF_"
|
640
|
+
@"PurposeCo"
|
641
|
+
@"nsents"]
|
642
|
+
= PurposeConsents;
|
643
|
+
result[@"IABTCF_"
|
644
|
+
@"TCString"]
|
645
|
+
= TCString;
|
646
|
+
[[NSUserDefaults
|
647
|
+
standardUserDefaults]
|
648
|
+
synchronize];
|
649
|
+
NSLog (
|
650
|
+
@"%@",
|
651
|
+
[[NSUserDefaults
|
652
|
+
standardUserDefaults]
|
653
|
+
dictionaryRepresentation]);
|
654
|
+
pluginResult = [CDVPluginResult
|
655
|
+
resultWithStatus:
|
656
|
+
CDVCommandStatus_OK
|
657
|
+
messageAsDictionary:
|
658
|
+
result];
|
659
|
+
[self
|
660
|
+
fireEvent:@""
|
661
|
+
event:
|
662
|
+
@"on."
|
663
|
+
@"getI"
|
664
|
+
@"abTf"
|
665
|
+
@"c"
|
666
|
+
withData:nil];
|
667
|
+
}
|
668
|
+
else
|
669
|
+
{
|
670
|
+
pluginResult = [CDVPluginResult
|
671
|
+
resultWithStatus:
|
672
|
+
CDVCommandStatus_ERROR];
|
673
|
+
}
|
674
|
+
[self.commandDelegate
|
675
|
+
sendPluginResult:
|
676
|
+
pluginResult
|
677
|
+
callbackId:
|
678
|
+
callbackId];
|
679
|
+
}
|
680
|
+
- (void)consentReset:
|
681
|
+
(CDVInvokedUrlCommand
|
682
|
+
*)command
|
683
|
+
{
|
684
|
+
CDVPluginResult
|
685
|
+
*pluginResult;
|
686
|
+
NSString *callbackId
|
687
|
+
= command
|
688
|
+
.callbackId;
|
689
|
+
@try
|
690
|
+
{
|
691
|
+
[[UMPConsentInformation
|
692
|
+
sharedInstance]
|
693
|
+
reset];
|
694
|
+
pluginResult = [CDVPluginResult
|
695
|
+
resultWithStatus:
|
696
|
+
CDVCommandStatus_OK];
|
697
|
+
}
|
698
|
+
@catch (
|
699
|
+
NSException
|
700
|
+
*exception)
|
701
|
+
{
|
702
|
+
pluginResult = [CDVPluginResult
|
703
|
+
resultWithStatus:
|
704
|
+
CDVCommandStatus_ERROR
|
705
|
+
messageAsString:
|
706
|
+
exception
|
707
|
+
.reason];
|
708
|
+
}
|
709
|
+
[self.commandDelegate
|
710
|
+
sendPluginResult:
|
711
|
+
pluginResult
|
712
|
+
callbackId:
|
713
|
+
callbackId];
|
714
|
+
}
|
715
|
+
- (void)
|
716
|
+
setPublisherFirstPartyIDEnabled:
|
717
|
+
(BOOL)enabled
|
718
|
+
{
|
719
|
+
};
|
720
|
+
- (void)globalSettings:
|
721
|
+
(CDVInvokedUrlCommand
|
722
|
+
*)command
|
723
|
+
{
|
724
|
+
CDVPluginResult
|
725
|
+
*pluginResult;
|
726
|
+
NSString *callbackId
|
727
|
+
= command
|
728
|
+
.callbackId;
|
729
|
+
BOOL setAppMuted =
|
730
|
+
[[command
|
731
|
+
argumentAtIndex:
|
732
|
+
0]
|
733
|
+
boolValue];
|
734
|
+
float setAppVolume =
|
735
|
+
[[command
|
736
|
+
argumentAtIndex:
|
737
|
+
1]
|
738
|
+
floatValue];
|
739
|
+
BOOL
|
740
|
+
publisherFirstPartyIdEnabled
|
741
|
+
= [[command
|
742
|
+
argumentAtIndex:
|
743
|
+
3]
|
744
|
+
boolValue];
|
745
|
+
NSString *npa =
|
746
|
+
[command.arguments
|
747
|
+
objectAtIndex:
|
748
|
+
2];
|
749
|
+
BOOL
|
750
|
+
enableCollapsible
|
751
|
+
= [[command
|
752
|
+
argumentAtIndex:
|
753
|
+
3]
|
754
|
+
boolValue];
|
755
|
+
BOOL responseInfo =
|
756
|
+
[[command
|
757
|
+
argumentAtIndex:
|
758
|
+
4]
|
759
|
+
boolValue];
|
760
|
+
BOOL
|
761
|
+
setDebugGeography
|
762
|
+
= [[command
|
763
|
+
argumentAtIndex:
|
764
|
+
5]
|
765
|
+
boolValue];
|
766
|
+
@try
|
767
|
+
{
|
768
|
+
GADMobileAds
|
769
|
+
.sharedInstance
|
770
|
+
.applicationVolume
|
771
|
+
= setAppVolume;
|
772
|
+
GADMobileAds
|
773
|
+
.sharedInstance
|
774
|
+
.applicationMuted
|
775
|
+
= setAppMuted;
|
776
|
+
[self
|
777
|
+
setPublisherFirstPartyIDEnabled:
|
778
|
+
publisherFirstPartyIdEnabled];
|
779
|
+
Npa = npa;
|
780
|
+
EnableCollapsible
|
781
|
+
= enableCollapsible;
|
782
|
+
ResponseInfo
|
783
|
+
= responseInfo;
|
784
|
+
isDebugGeography
|
785
|
+
= setDebugGeography;
|
786
|
+
pluginResult = [CDVPluginResult
|
787
|
+
resultWithStatus:
|
788
|
+
CDVCommandStatus_OK];
|
789
|
+
}
|
790
|
+
@catch (
|
791
|
+
NSException
|
792
|
+
*exception)
|
793
|
+
{
|
794
|
+
pluginResult = [CDVPluginResult
|
795
|
+
resultWithStatus:
|
796
|
+
CDVCommandStatus_ERROR
|
797
|
+
messageAsString:
|
798
|
+
exception
|
799
|
+
.reason];
|
800
|
+
}
|
801
|
+
[self.commandDelegate
|
802
|
+
sendPluginResult:
|
803
|
+
pluginResult
|
804
|
+
callbackId:
|
805
|
+
callbackId];
|
806
|
+
}
|
807
|
+
- (void)targeting:
|
808
|
+
(CDVInvokedUrlCommand
|
809
|
+
*)command
|
810
|
+
{
|
811
|
+
CDVPluginResult
|
812
|
+
*pluginResult;
|
813
|
+
NSString *callbackId
|
814
|
+
= command
|
815
|
+
.callbackId;
|
816
|
+
NSNumber *
|
817
|
+
childDirectedTreatment
|
818
|
+
= [command
|
819
|
+
argumentAtIndex:
|
820
|
+
0];
|
821
|
+
NSNumber *
|
822
|
+
underAgeOfConsent
|
823
|
+
= [command
|
824
|
+
argumentAtIndex:
|
825
|
+
1];
|
826
|
+
NSString
|
827
|
+
*contentRating
|
828
|
+
= [command
|
829
|
+
argumentAtIndex:
|
830
|
+
2];
|
831
|
+
@try
|
832
|
+
{
|
833
|
+
GADRequestConfiguration
|
834
|
+
*requestConfiguration
|
835
|
+
= GADMobileAds
|
836
|
+
.sharedInstance
|
837
|
+
.requestConfiguration;
|
838
|
+
requestConfiguration
|
839
|
+
.tagForChildDirectedTreatment
|
840
|
+
= childDirectedTreatment;
|
841
|
+
requestConfiguration
|
842
|
+
.tagForUnderAgeOfConsent
|
843
|
+
= underAgeOfConsent;
|
844
|
+
requestConfiguration
|
845
|
+
.maxAdContentRating
|
846
|
+
= contentRating;
|
847
|
+
UnderAgeOfConsent
|
848
|
+
= underAgeOfConsent;
|
849
|
+
}
|
850
|
+
@catch (
|
851
|
+
NSException
|
852
|
+
*exception)
|
853
|
+
{
|
854
|
+
pluginResult = [CDVPluginResult
|
855
|
+
resultWithStatus:
|
856
|
+
CDVCommandStatus_ERROR
|
857
|
+
messageAsString:
|
858
|
+
exception
|
859
|
+
.reason];
|
860
|
+
}
|
861
|
+
[self.commandDelegate
|
862
|
+
sendPluginResult:
|
863
|
+
pluginResult
|
864
|
+
callbackId:
|
865
|
+
callbackId];
|
866
|
+
}
|
867
|
+
- (GADAdSize)
|
868
|
+
__AdSizeFromString:
|
869
|
+
(NSString *)
|
870
|
+
size
|
871
|
+
{
|
872
|
+
if ([size
|
873
|
+
isEqualToString:
|
874
|
+
@"ANCHOR"
|
875
|
+
@"ED"])
|
876
|
+
{
|
877
|
+
return GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth (
|
878
|
+
adWidth);
|
879
|
+
}
|
880
|
+
else if (
|
881
|
+
[size
|
882
|
+
isEqualToString:
|
883
|
+
@"IN_"
|
884
|
+
@"LINE"])
|
885
|
+
{
|
886
|
+
return GADCurrentOrientationInlineAdaptiveBannerAdSizeWithWidth (
|
887
|
+
adWidth);
|
888
|
+
}
|
889
|
+
else if (
|
890
|
+
[size
|
891
|
+
isEqualToString:
|
892
|
+
@"BANNE"
|
893
|
+
@"R"])
|
894
|
+
{
|
895
|
+
return GADAdSizeBanner;
|
896
|
+
}
|
897
|
+
else if (
|
898
|
+
[size
|
899
|
+
isEqualToString:
|
900
|
+
@"LARGE_"
|
901
|
+
@"BANNE"
|
902
|
+
@"R"])
|
903
|
+
{
|
904
|
+
return GADAdSizeLargeBanner;
|
905
|
+
}
|
906
|
+
else if (
|
907
|
+
[size
|
908
|
+
isEqualToString:
|
909
|
+
@"FULL_"
|
910
|
+
@"BANNE"
|
911
|
+
@"R"])
|
912
|
+
{
|
913
|
+
return GADAdSizeFullBanner;
|
914
|
+
}
|
915
|
+
else if (
|
916
|
+
[size
|
917
|
+
isEqualToString:
|
918
|
+
@"LEADER"
|
919
|
+
@"BOAR"
|
920
|
+
@"D"])
|
921
|
+
{
|
922
|
+
return GADAdSizeLeaderboard;
|
923
|
+
}
|
924
|
+
else
|
925
|
+
{
|
926
|
+
return GADAdSizeBanner;
|
927
|
+
}
|
928
|
+
}
|
929
|
+
- (void)loadBannerAd:
|
930
|
+
(CDVInvokedUrlCommand
|
931
|
+
*)command
|
932
|
+
{
|
933
|
+
|
934
|
+
CDVPluginResult
|
935
|
+
*pluginResult;
|
936
|
+
NSString *callbackId
|
937
|
+
= command
|
938
|
+
.callbackId;
|
939
|
+
adFormat = 3;
|
940
|
+
if (adFormat == 3)
|
941
|
+
{
|
942
|
+
dispatch_async (dispatch_get_main_queue (), ^{
|
943
|
+
UIView
|
944
|
+
*parentView
|
945
|
+
= [self.webView
|
946
|
+
superview];
|
947
|
+
NSString
|
948
|
+
*adUnitId
|
949
|
+
= [command
|
950
|
+
.arguments
|
951
|
+
objectAtIndex:
|
952
|
+
0];
|
953
|
+
NSString
|
954
|
+
*position
|
955
|
+
= [command
|
956
|
+
.arguments
|
957
|
+
objectAtIndex:
|
958
|
+
1];
|
959
|
+
NSString *size =
|
960
|
+
[command.arguments
|
961
|
+
objectAtIndex:
|
962
|
+
2];
|
963
|
+
NSString
|
964
|
+
*collapsible
|
965
|
+
= [command
|
966
|
+
.arguments
|
967
|
+
objectAtIndex:
|
968
|
+
3];
|
969
|
+
NSNumber *
|
970
|
+
adaptive_Width
|
971
|
+
= [command
|
972
|
+
.arguments
|
973
|
+
objectAtIndex:
|
974
|
+
4];
|
975
|
+
BOOL autoShow = [[command
|
976
|
+
argumentAtIndex:
|
977
|
+
5]
|
978
|
+
boolValue];
|
979
|
+
auto_Show
|
980
|
+
= autoShow;
|
981
|
+
int intValue =
|
982
|
+
[adaptive_Width
|
983
|
+
intValue];
|
984
|
+
adWidth
|
985
|
+
= intValue;
|
986
|
+
Position
|
987
|
+
= position;
|
988
|
+
GADAdSize sizes = [self
|
989
|
+
__AdSizeFromString:
|
990
|
+
size];
|
991
|
+
self.bannerView =
|
992
|
+
[[GADBannerView
|
993
|
+
alloc]
|
994
|
+
initWithAdSize:
|
995
|
+
sizes];
|
996
|
+
GADRequest
|
997
|
+
*request
|
998
|
+
= [GADRequest
|
999
|
+
request];
|
1000
|
+
GADExtras *extras
|
1001
|
+
= [[GADExtras
|
1002
|
+
alloc]
|
1003
|
+
init];
|
1004
|
+
if (EnableCollapsible)
|
1005
|
+
{
|
1006
|
+
extras
|
1007
|
+
.additionalParameters
|
1008
|
+
= @{
|
1009
|
+
@"colla"
|
1010
|
+
@"psibl"
|
1011
|
+
@"e" :
|
1012
|
+
collapsible
|
1013
|
+
};
|
1014
|
+
}
|
1015
|
+
extras
|
1016
|
+
.additionalParameters
|
1017
|
+
= @{
|
1018
|
+
@"npa" :
|
1019
|
+
Npa
|
1020
|
+
};
|
1021
|
+
[request
|
1022
|
+
registerAdNetworkExtras:
|
1023
|
+
extras];
|
1024
|
+
self.bannerView
|
1025
|
+
.adUnitID
|
1026
|
+
= adUnitId;
|
1027
|
+
self.bannerView
|
1028
|
+
.rootViewController
|
1029
|
+
= self.viewController;
|
1030
|
+
self.bannerView
|
1031
|
+
.delegate
|
1032
|
+
= self;
|
1033
|
+
[self.bannerView
|
1034
|
+
loadRequest:
|
1035
|
+
request];
|
1036
|
+
self.bannerView
|
1037
|
+
.hidden
|
1038
|
+
= YES;
|
1039
|
+
[parentView
|
1040
|
+
addSubview:
|
1041
|
+
self.bannerView];
|
1042
|
+
[parentView
|
1043
|
+
bringSubviewToFront:
|
1044
|
+
self.bannerView];
|
1045
|
+
});
|
1046
|
+
pluginResult = [CDVPluginResult
|
1047
|
+
resultWithStatus:
|
1048
|
+
CDVCommandStatus_OK];
|
1049
|
+
}
|
1050
|
+
else
|
1051
|
+
{
|
1052
|
+
NSLog (
|
1053
|
+
@"Admob "
|
1054
|
+
@"Option "
|
1055
|
+
@"invalid for "
|
1056
|
+
@"banner");
|
1057
|
+
pluginResult = [CDVPluginResult
|
1058
|
+
resultWithStatus:
|
1059
|
+
CDVCommandStatus_ERROR];
|
1060
|
+
}
|
1061
|
+
[self.commandDelegate
|
1062
|
+
sendPluginResult:
|
1063
|
+
pluginResult
|
1064
|
+
callbackId:
|
1065
|
+
callbackId];
|
1066
|
+
}
|
1067
|
+
- (void)showBannerAd:
|
1068
|
+
(CDVInvokedUrlCommand
|
1069
|
+
*)command
|
1070
|
+
{
|
1071
|
+
CDVPluginResult
|
1072
|
+
*pluginResult;
|
1073
|
+
NSString *callbackId
|
1074
|
+
= command
|
1075
|
+
.callbackId;
|
1076
|
+
if (self.bannerView)
|
1077
|
+
{
|
1078
|
+
self.bannerView
|
1079
|
+
.hidden
|
1080
|
+
= NO;
|
1081
|
+
[self
|
1082
|
+
addBannerViewToView:
|
1083
|
+
command];
|
1084
|
+
pluginResult = [CDVPluginResult
|
1085
|
+
resultWithStatus:
|
1086
|
+
CDVCommandStatus_OK];
|
1087
|
+
}
|
1088
|
+
else
|
1089
|
+
{
|
1090
|
+
[self
|
1091
|
+
fireEvent:@""
|
1092
|
+
event:
|
1093
|
+
@"on."
|
1094
|
+
@"bann"
|
1095
|
+
@"er."
|
1096
|
+
@"fail"
|
1097
|
+
@"ed."
|
1098
|
+
@"show"
|
1099
|
+
withData:nil];
|
1100
|
+
pluginResult = [CDVPluginResult
|
1101
|
+
resultWithStatus:
|
1102
|
+
CDVCommandStatus_ERROR];
|
1103
|
+
}
|
1104
|
+
[self.commandDelegate
|
1105
|
+
sendPluginResult:
|
1106
|
+
pluginResult
|
1107
|
+
callbackId:
|
1108
|
+
callbackId];
|
1109
|
+
}
|
1110
|
+
- (void)
|
1111
|
+
addBannerViewToView:
|
1112
|
+
(CDVInvokedUrlCommand
|
1113
|
+
*)command
|
1114
|
+
{
|
1115
|
+
bannerView
|
1116
|
+
.translatesAutoresizingMaskIntoConstraints
|
1117
|
+
= NO;
|
1118
|
+
[self.viewController
|
1119
|
+
.view
|
1120
|
+
addSubview:
|
1121
|
+
bannerView];
|
1122
|
+
if ([Position
|
1123
|
+
isEqualToString:
|
1124
|
+
@"bottom"
|
1125
|
+
@"-cente"
|
1126
|
+
@"r"])
|
1127
|
+
{
|
1128
|
+
[self.viewController
|
1129
|
+
.view addConstraints:@[
|
1130
|
+
[NSLayoutConstraint
|
1131
|
+
constraintWithItem:
|
1132
|
+
bannerView
|
1133
|
+
attribute:
|
1134
|
+
NSLayoutAttributeBottom
|
1135
|
+
relatedBy:
|
1136
|
+
NSLayoutRelationEqual
|
1137
|
+
toItem:
|
1138
|
+
self.viewController
|
1139
|
+
.view
|
1140
|
+
.safeAreaLayoutGuide
|
1141
|
+
attribute:
|
1142
|
+
NSLayoutAttributeBottom
|
1143
|
+
multiplier:
|
1144
|
+
1
|
1145
|
+
constant:
|
1146
|
+
0],
|
1147
|
+
[NSLayoutConstraint
|
1148
|
+
constraintWithItem:
|
1149
|
+
bannerView
|
1150
|
+
attribute:
|
1151
|
+
NSLayoutAttributeCenterX
|
1152
|
+
relatedBy:
|
1153
|
+
NSLayoutRelationEqual
|
1154
|
+
toItem:
|
1155
|
+
self.viewController
|
1156
|
+
.view
|
1157
|
+
attribute:
|
1158
|
+
NSLayoutAttributeCenterX
|
1159
|
+
multiplier:
|
1160
|
+
1
|
1161
|
+
constant:
|
1162
|
+
0]
|
1163
|
+
]];
|
1164
|
+
}
|
1165
|
+
else
|
1166
|
+
{
|
1167
|
+
[self.viewController
|
1168
|
+
.view addConstraints:@[
|
1169
|
+
[NSLayoutConstraint
|
1170
|
+
constraintWithItem:
|
1171
|
+
bannerView
|
1172
|
+
attribute:
|
1173
|
+
NSLayoutAttributeTop
|
1174
|
+
relatedBy:
|
1175
|
+
NSLayoutRelationEqual
|
1176
|
+
toItem:
|
1177
|
+
self.viewController
|
1178
|
+
.view
|
1179
|
+
.safeAreaLayoutGuide
|
1180
|
+
attribute:
|
1181
|
+
NSLayoutAttributeTop
|
1182
|
+
multiplier:
|
1183
|
+
1
|
1184
|
+
constant:
|
1185
|
+
0],
|
1186
|
+
[NSLayoutConstraint
|
1187
|
+
constraintWithItem:
|
1188
|
+
bannerView
|
1189
|
+
attribute:
|
1190
|
+
NSLayoutAttributeCenterX
|
1191
|
+
relatedBy:
|
1192
|
+
NSLayoutRelationEqual
|
1193
|
+
toItem:
|
1194
|
+
self.viewController
|
1195
|
+
.view
|
1196
|
+
attribute:
|
1197
|
+
NSLayoutAttributeCenterX
|
1198
|
+
multiplier:
|
1199
|
+
1
|
1200
|
+
constant:
|
1201
|
+
0]
|
1202
|
+
]];
|
1203
|
+
}
|
1204
|
+
}
|
1205
|
+
- (void)hideBannerAd:
|
1206
|
+
(CDVInvokedUrlCommand
|
1207
|
+
*)command
|
1208
|
+
{
|
1209
|
+
CDVPluginResult
|
1210
|
+
*pluginResult;
|
1211
|
+
NSString *callbackId
|
1212
|
+
= command
|
1213
|
+
.callbackId;
|
1214
|
+
if (self.bannerView)
|
1215
|
+
{
|
1216
|
+
dispatch_async (
|
1217
|
+
dispatch_get_main_queue (),
|
1218
|
+
^{
|
1219
|
+
self.bannerView
|
1220
|
+
.hidden
|
1221
|
+
= YES;
|
1222
|
+
[self
|
1223
|
+
fireEvent:
|
1224
|
+
@""
|
1225
|
+
event:
|
1226
|
+
@"on.banner.hide"
|
1227
|
+
withData:
|
1228
|
+
nil];
|
1229
|
+
});
|
1230
|
+
pluginResult = [CDVPluginResult
|
1231
|
+
resultWithStatus:
|
1232
|
+
CDVCommandStatus_OK];
|
1233
|
+
}
|
1234
|
+
else
|
1235
|
+
{
|
1236
|
+
pluginResult = [CDVPluginResult
|
1237
|
+
resultWithStatus:
|
1238
|
+
CDVCommandStatus_ERROR];
|
1239
|
+
}
|
1240
|
+
[self.commandDelegate
|
1241
|
+
sendPluginResult:
|
1242
|
+
pluginResult
|
1243
|
+
callbackId:
|
1244
|
+
callbackId];
|
1245
|
+
}
|
1246
|
+
- (void)removeBannerAd:
|
1247
|
+
(CDVInvokedUrlCommand
|
1248
|
+
*)command
|
1249
|
+
{
|
1250
|
+
CDVPluginResult
|
1251
|
+
*pluginResult;
|
1252
|
+
NSString *callbackId
|
1253
|
+
= command
|
1254
|
+
.callbackId;
|
1255
|
+
if (self.bannerView)
|
1256
|
+
{
|
1257
|
+
dispatch_async (
|
1258
|
+
dispatch_get_main_queue (),
|
1259
|
+
^{
|
1260
|
+
self.bannerView
|
1261
|
+
.hidden
|
1262
|
+
= YES;
|
1263
|
+
[self.bannerView
|
1264
|
+
removeFromSuperview];
|
1265
|
+
self.bannerView
|
1266
|
+
= nil;
|
1267
|
+
[self
|
1268
|
+
fireEvent:
|
1269
|
+
@""
|
1270
|
+
event:
|
1271
|
+
@"on.banner.remove"
|
1272
|
+
withData:
|
1273
|
+
nil];
|
1274
|
+
});
|
1275
|
+
pluginResult = [CDVPluginResult
|
1276
|
+
resultWithStatus:
|
1277
|
+
CDVCommandStatus_OK];
|
1278
|
+
}
|
1279
|
+
else
|
1280
|
+
{
|
1281
|
+
pluginResult = [CDVPluginResult
|
1282
|
+
resultWithStatus:
|
1283
|
+
CDVCommandStatus_ERROR];
|
1284
|
+
}
|
1285
|
+
[self.commandDelegate
|
1286
|
+
sendPluginResult:
|
1287
|
+
pluginResult
|
1288
|
+
callbackId:
|
1289
|
+
callbackId];
|
1290
|
+
}
|
1291
|
+
- (void)loadAppOpenAd:
|
1292
|
+
(CDVInvokedUrlCommand
|
1293
|
+
*)command
|
1294
|
+
{
|
1295
|
+
CDVPluginResult
|
1296
|
+
*pluginResult;
|
1297
|
+
NSString *callbackId
|
1298
|
+
= command
|
1299
|
+
.callbackId;
|
1300
|
+
NSString *adUnitId =
|
1301
|
+
[command.arguments
|
1302
|
+
objectAtIndex:
|
1303
|
+
0];
|
1304
|
+
BOOL autoShow = [[command
|
1305
|
+
argumentAtIndex:
|
1306
|
+
1]
|
1307
|
+
boolValue];
|
1308
|
+
auto_Show = autoShow;
|
1309
|
+
adFormat = 1;
|
1310
|
+
self.appOpenAd = nil;
|
1311
|
+
if (adFormat == 1)
|
1312
|
+
{
|
1313
|
+
dispatch_async (dispatch_get_main_queue (), ^{
|
1314
|
+
GADRequest
|
1315
|
+
*request
|
1316
|
+
= [GADRequest
|
1317
|
+
request];
|
1318
|
+
GADExtras *extras
|
1319
|
+
= [[GADExtras
|
1320
|
+
alloc]
|
1321
|
+
init];
|
1322
|
+
extras
|
1323
|
+
.additionalParameters
|
1324
|
+
= @{
|
1325
|
+
@"npa" :
|
1326
|
+
Npa
|
1327
|
+
};
|
1328
|
+
[request
|
1329
|
+
registerAdNetworkExtras:
|
1330
|
+
extras];
|
1331
|
+
[GADAppOpenAd
|
1332
|
+
loadWithAdUnitID:
|
1333
|
+
adUnitId
|
1334
|
+
request:
|
1335
|
+
request
|
1336
|
+
orientation:
|
1337
|
+
UIInterfaceOrientationPortrait
|
1338
|
+
|
1339
|
+
completionHandler:^(
|
1340
|
+
GADAppOpenAd
|
1341
|
+
*ad,
|
1342
|
+
NSError *
|
1343
|
+
error) {
|
1344
|
+
if (error)
|
1345
|
+
{
|
1346
|
+
[self
|
1347
|
+
fireEvent:
|
1348
|
+
@""
|
1349
|
+
event:
|
1350
|
+
@"on.appOpenAd.failed.loaded"
|
1351
|
+
withData:
|
1352
|
+
nil];
|
1353
|
+
NSLog (
|
1354
|
+
@"Fa"
|
1355
|
+
@"il"
|
1356
|
+
@"ed"
|
1357
|
+
@" t"
|
1358
|
+
@"o "
|
1359
|
+
@"lo"
|
1360
|
+
@"ad"
|
1361
|
+
@" A"
|
1362
|
+
@"pp"
|
1363
|
+
@" O"
|
1364
|
+
@"pe"
|
1365
|
+
@"n "
|
1366
|
+
@"Ad"
|
1367
|
+
@" a"
|
1368
|
+
@"d "
|
1369
|
+
@"wi"
|
1370
|
+
@"th"
|
1371
|
+
@" e"
|
1372
|
+
@"rr"
|
1373
|
+
@"or"
|
1374
|
+
@": "
|
1375
|
+
@"%"
|
1376
|
+
@"@",
|
1377
|
+
[error
|
1378
|
+
localizedDescription]);
|
1379
|
+
return;
|
1380
|
+
}
|
1381
|
+
self.appOpenAd
|
1382
|
+
= ad;
|
1383
|
+
self.appOpenAd
|
1384
|
+
.fullScreenContentDelegate
|
1385
|
+
= self;
|
1386
|
+
[self
|
1387
|
+
fireEvent:
|
1388
|
+
@""
|
1389
|
+
event:
|
1390
|
+
@"on.appOpenAd.loaded"
|
1391
|
+
withData:
|
1392
|
+
nil];
|
1393
|
+
if (auto_Show)
|
1394
|
+
{
|
1395
|
+
if (self.appOpenAd
|
1396
|
+
&&
|
1397
|
+
[self.appOpenAd
|
1398
|
+
canPresentFromRootViewController:
|
1399
|
+
self.viewController
|
1400
|
+
error:
|
1401
|
+
nil])
|
1402
|
+
{
|
1403
|
+
[self.appOpenAd
|
1404
|
+
presentFromRootViewController:
|
1405
|
+
self.viewController];
|
1406
|
+
}
|
1407
|
+
else
|
1408
|
+
{
|
1409
|
+
[self
|
1410
|
+
fireEvent:
|
1411
|
+
@""
|
1412
|
+
event:
|
1413
|
+
@"on.appOpenAd.failed.show"
|
1414
|
+
withData:
|
1415
|
+
nil];
|
1416
|
+
}
|
1417
|
+
}
|
1418
|
+
}];
|
1419
|
+
});
|
1420
|
+
pluginResult = [CDVPluginResult
|
1421
|
+
resultWithStatus:
|
1422
|
+
CDVCommandStatus_OK];
|
1423
|
+
}
|
1424
|
+
[self.commandDelegate
|
1425
|
+
sendPluginResult:
|
1426
|
+
pluginResult
|
1427
|
+
callbackId:
|
1428
|
+
callbackId];
|
1429
|
+
}
|
1430
|
+
- (void)showAppOpenAd:
|
1431
|
+
(CDVInvokedUrlCommand
|
1432
|
+
*)command
|
1433
|
+
{
|
1434
|
+
CDVPluginResult
|
1435
|
+
*pluginResult;
|
1436
|
+
NSString *callbackId
|
1437
|
+
= command
|
1438
|
+
.callbackId;
|
1439
|
+
if (self.appOpenAd &&
|
1440
|
+
[self.appOpenAd
|
1441
|
+
canPresentFromRootViewController:
|
1442
|
+
self.viewController
|
1443
|
+
error:
|
1444
|
+
nil])
|
1445
|
+
{
|
1446
|
+
[self.appOpenAd
|
1447
|
+
presentFromRootViewController:
|
1448
|
+
self.viewController];
|
1449
|
+
pluginResult = [CDVPluginResult
|
1450
|
+
resultWithStatus:
|
1451
|
+
CDVCommandStatus_OK];
|
1452
|
+
}
|
1453
|
+
else
|
1454
|
+
{
|
1455
|
+
pluginResult = [CDVPluginResult
|
1456
|
+
resultWithStatus:
|
1457
|
+
CDVCommandStatus_ERROR];
|
1458
|
+
[self
|
1459
|
+
fireEvent:@""
|
1460
|
+
event:
|
1461
|
+
@"on."
|
1462
|
+
@"appO"
|
1463
|
+
@"penA"
|
1464
|
+
@"d."
|
1465
|
+
@"fail"
|
1466
|
+
@"ed."
|
1467
|
+
@"show"
|
1468
|
+
withData:nil];
|
1469
|
+
}
|
1470
|
+
[self.commandDelegate
|
1471
|
+
sendPluginResult:
|
1472
|
+
pluginResult
|
1473
|
+
callbackId:
|
1474
|
+
callbackId];
|
1475
|
+
}
|
1476
|
+
- (void)
|
1477
|
+
loadInterstitialAd:
|
1478
|
+
(CDVInvokedUrlCommand
|
1479
|
+
*)command
|
1480
|
+
{
|
1481
|
+
CDVPluginResult
|
1482
|
+
*pluginResult;
|
1483
|
+
NSString *callbackId
|
1484
|
+
= command
|
1485
|
+
.callbackId;
|
1486
|
+
NSString *adUnitId =
|
1487
|
+
[command.arguments
|
1488
|
+
objectAtIndex:
|
1489
|
+
0];
|
1490
|
+
BOOL autoShow = [[command
|
1491
|
+
argumentAtIndex:
|
1492
|
+
1]
|
1493
|
+
boolValue];
|
1494
|
+
auto_Show = autoShow;
|
1495
|
+
adFormat = 2;
|
1496
|
+
if (adFormat == 2)
|
1497
|
+
{
|
1498
|
+
dispatch_async (dispatch_get_main_queue (), ^{
|
1499
|
+
GADRequest
|
1500
|
+
*request
|
1501
|
+
= [GADRequest
|
1502
|
+
request];
|
1503
|
+
[GADInterstitialAd
|
1504
|
+
loadWithAdUnitID:
|
1505
|
+
adUnitId
|
1506
|
+
request:
|
1507
|
+
request
|
1508
|
+
completionHandler:^(
|
1509
|
+
GADInterstitialAd
|
1510
|
+
*ad,
|
1511
|
+
NSError *
|
1512
|
+
error) {
|
1513
|
+
if (error)
|
1514
|
+
{
|
1515
|
+
NSLog (
|
1516
|
+
@"Fa"
|
1517
|
+
@"il"
|
1518
|
+
@"ed"
|
1519
|
+
@" t"
|
1520
|
+
@"o "
|
1521
|
+
@"lo"
|
1522
|
+
@"ad"
|
1523
|
+
@" i"
|
1524
|
+
@"nt"
|
1525
|
+
@"er"
|
1526
|
+
@"st"
|
1527
|
+
@"it"
|
1528
|
+
@"ia"
|
1529
|
+
@"l "
|
1530
|
+
@"ad"
|
1531
|
+
@" w"
|
1532
|
+
@"it"
|
1533
|
+
@"h "
|
1534
|
+
@"er"
|
1535
|
+
@"ro"
|
1536
|
+
@"r:"
|
1537
|
+
@" %"
|
1538
|
+
@"@",
|
1539
|
+
[error
|
1540
|
+
localizedDescription]);
|
1541
|
+
}
|
1542
|
+
self.interstitial
|
1543
|
+
= ad;
|
1544
|
+
self.interstitial
|
1545
|
+
.fullScreenContentDelegate
|
1546
|
+
= self;
|
1547
|
+
[self
|
1548
|
+
fireEvent:
|
1549
|
+
@""
|
1550
|
+
event:
|
1551
|
+
@"on.interstitial.loaded"
|
1552
|
+
withData:
|
1553
|
+
nil];
|
1554
|
+
if (auto_Show)
|
1555
|
+
{
|
1556
|
+
if (self.interstitial
|
1557
|
+
&&
|
1558
|
+
[self.interstitial
|
1559
|
+
canPresentFromRootViewController:
|
1560
|
+
self.viewController
|
1561
|
+
error:
|
1562
|
+
nil])
|
1563
|
+
{
|
1564
|
+
[self.interstitial
|
1565
|
+
presentFromRootViewController:
|
1566
|
+
self.viewController];
|
1567
|
+
}
|
1568
|
+
else
|
1569
|
+
{
|
1570
|
+
[self
|
1571
|
+
fireEvent:
|
1572
|
+
@""
|
1573
|
+
event:
|
1574
|
+
@"on.interstitial.failed.show"
|
1575
|
+
withData:
|
1576
|
+
nil];
|
1577
|
+
}
|
1578
|
+
}
|
1579
|
+
}];
|
1580
|
+
});
|
1581
|
+
}
|
1582
|
+
pluginResult = [CDVPluginResult
|
1583
|
+
resultWithStatus:
|
1584
|
+
CDVCommandStatus_OK];
|
1585
|
+
[self.commandDelegate
|
1586
|
+
sendPluginResult:
|
1587
|
+
pluginResult
|
1588
|
+
callbackId:
|
1589
|
+
callbackId];
|
1590
|
+
}
|
1591
|
+
- (void)
|
1592
|
+
showInterstitialAd:
|
1593
|
+
(CDVInvokedUrlCommand
|
1594
|
+
*)command
|
1595
|
+
{
|
1596
|
+
CDVPluginResult
|
1597
|
+
*pluginResult;
|
1598
|
+
NSString *callbackId
|
1599
|
+
= command
|
1600
|
+
.callbackId;
|
1601
|
+
if (self.interstitial
|
1602
|
+
&&
|
1603
|
+
[self.interstitial
|
1604
|
+
canPresentFromRootViewController:
|
1605
|
+
self.viewController
|
1606
|
+
error:
|
1607
|
+
nil])
|
1608
|
+
{
|
1609
|
+
[self.interstitial
|
1610
|
+
presentFromRootViewController:
|
1611
|
+
self.viewController];
|
1612
|
+
pluginResult = [CDVPluginResult
|
1613
|
+
resultWithStatus:
|
1614
|
+
CDVCommandStatus_OK];
|
1615
|
+
}
|
1616
|
+
else
|
1617
|
+
{
|
1618
|
+
pluginResult = [CDVPluginResult
|
1619
|
+
resultWithStatus:
|
1620
|
+
CDVCommandStatus_ERROR];
|
1621
|
+
[self
|
1622
|
+
fireEvent:@""
|
1623
|
+
event:
|
1624
|
+
@"on."
|
1625
|
+
@"inte"
|
1626
|
+
@"rsti"
|
1627
|
+
@"tial"
|
1628
|
+
@".fai"
|
1629
|
+
@"led."
|
1630
|
+
@"show"
|
1631
|
+
withData:nil];
|
1632
|
+
}
|
1633
|
+
[self.commandDelegate
|
1634
|
+
sendPluginResult:
|
1635
|
+
pluginResult
|
1636
|
+
callbackId:
|
1637
|
+
callbackId];
|
1638
|
+
}
|
1639
|
+
- (void)
|
1640
|
+
loadRewardedInterstitialAd:
|
1641
|
+
(CDVInvokedUrlCommand
|
1642
|
+
*)command
|
1643
|
+
{
|
1644
|
+
CDVPluginResult
|
1645
|
+
*pluginResult;
|
1646
|
+
NSString *callbackId
|
1647
|
+
= command
|
1648
|
+
.callbackId;
|
1649
|
+
NSString *adUnitId =
|
1650
|
+
[command.arguments
|
1651
|
+
objectAtIndex:
|
1652
|
+
0];
|
1653
|
+
BOOL autoShow = [[command
|
1654
|
+
argumentAtIndex:
|
1655
|
+
1]
|
1656
|
+
boolValue];
|
1657
|
+
auto_Show = autoShow;
|
1658
|
+
adFormat = 4;
|
1659
|
+
if (adFormat == 4)
|
1660
|
+
{
|
1661
|
+
dispatch_async (
|
1662
|
+
dispatch_get_main_queue (),
|
1663
|
+
^{
|
1664
|
+
GADRequest
|
1665
|
+
*request
|
1666
|
+
= [GADRequest
|
1667
|
+
request];
|
1668
|
+
[GADRewardedInterstitialAd loadWithAdUnitID:
|
1669
|
+
adUnitId
|
1670
|
+
request:
|
1671
|
+
request
|
1672
|
+
completionHandler:
|
1673
|
+
^(GADRewardedInterstitialAd *ad, NSError
|
1674
|
+
*error) {
|
1675
|
+
if (error)
|
1676
|
+
{
|
1677
|
+
NSLog (
|
1678
|
+
@"Rewarded ad failed to load with error: %@",
|
1679
|
+
[error
|
1680
|
+
localizedDescription]);
|
1681
|
+
return;
|
1682
|
+
}
|
1683
|
+
self.rewardedInterstitialAd
|
1684
|
+
= ad;
|
1685
|
+
isAdSkip
|
1686
|
+
= 1;
|
1687
|
+
NSLog (
|
1688
|
+
@"Rewarded ad loaded.");
|
1689
|
+
self.rewardedInterstitialAd
|
1690
|
+
.fullScreenContentDelegate
|
1691
|
+
= self;
|
1692
|
+
[self
|
1693
|
+
fireEvent:
|
1694
|
+
@""
|
1695
|
+
event:
|
1696
|
+
@"on.rewardedInt.loaded"
|
1697
|
+
withData:
|
1698
|
+
nil];
|
1699
|
+
if (auto_Show)
|
1700
|
+
{
|
1701
|
+
if (self.rewardedInterstitialAd
|
1702
|
+
&&
|
1703
|
+
[self.rewardedInterstitialAd
|
1704
|
+
canPresentFromRootViewController:
|
1705
|
+
self.viewController
|
1706
|
+
error:
|
1707
|
+
nil])
|
1708
|
+
{
|
1709
|
+
[self.rewardedInterstitialAd presentFromRootViewController:
|
1710
|
+
self.viewController
|
1711
|
+
userDidEarnRewardHandler:^{
|
1712
|
+
GADAdReward
|
1713
|
+
*reward
|
1714
|
+
= self.rewardedInterstitialAd
|
1715
|
+
.adReward;
|
1716
|
+
[self
|
1717
|
+
fireEvent:
|
1718
|
+
@""
|
1719
|
+
event:
|
1720
|
+
@"on.rewardedInt.userEarnedReward"
|
1721
|
+
withData:
|
1722
|
+
nil];
|
1723
|
+
isAdSkip
|
1724
|
+
= 2;
|
1725
|
+
NSString
|
1726
|
+
*rewardMessage
|
1727
|
+
= [NSString
|
1728
|
+
stringWithFormat:
|
1729
|
+
@"Reward received with "
|
1730
|
+
@"currency %@ , amount %ld",
|
1731
|
+
reward
|
1732
|
+
.type,
|
1733
|
+
[reward.amount
|
1734
|
+
longValue]];
|
1735
|
+
NSLog (
|
1736
|
+
@"%@",
|
1737
|
+
rewardMessage);
|
1738
|
+
}];
|
1739
|
+
}
|
1740
|
+
else
|
1741
|
+
{
|
1742
|
+
[self
|
1743
|
+
fireEvent:
|
1744
|
+
@""
|
1745
|
+
event:
|
1746
|
+
@"on.rewardedInt.failed.show"
|
1747
|
+
withData:
|
1748
|
+
nil];
|
1749
|
+
}
|
1750
|
+
}
|
1751
|
+
}];
|
1752
|
+
});
|
1753
|
+
}
|
1754
|
+
pluginResult = [CDVPluginResult
|
1755
|
+
resultWithStatus:
|
1756
|
+
CDVCommandStatus_OK];
|
1757
|
+
[self.commandDelegate
|
1758
|
+
sendPluginResult:
|
1759
|
+
pluginResult
|
1760
|
+
callbackId:
|
1761
|
+
callbackId];
|
1762
|
+
}
|
1763
|
+
- (void)
|
1764
|
+
showRewardedInterstitialAd:
|
1765
|
+
(CDVInvokedUrlCommand
|
1766
|
+
*)command
|
1767
|
+
{
|
1768
|
+
CDVPluginResult
|
1769
|
+
*pluginResult;
|
1770
|
+
NSString *callbackId
|
1771
|
+
= command
|
1772
|
+
.callbackId;
|
1773
|
+
if (self.rewardedInterstitialAd
|
1774
|
+
&&
|
1775
|
+
[self.rewardedInterstitialAd
|
1776
|
+
canPresentFromRootViewController:
|
1777
|
+
self.viewController
|
1778
|
+
error:
|
1779
|
+
nil])
|
1780
|
+
{
|
1781
|
+
[self.rewardedInterstitialAd
|
1782
|
+
presentFromRootViewController:
|
1783
|
+
self.viewController
|
1784
|
+
userDidEarnRewardHandler:^{
|
1785
|
+
GADAdReward
|
1786
|
+
*reward
|
1787
|
+
= self.rewardedInterstitialAd
|
1788
|
+
.adReward;
|
1789
|
+
[self
|
1790
|
+
fireEvent:
|
1791
|
+
@""
|
1792
|
+
event:
|
1793
|
+
@"on.rewardedInt.userEarnedReward"
|
1794
|
+
withData:
|
1795
|
+
nil];
|
1796
|
+
isAdSkip
|
1797
|
+
= 2;
|
1798
|
+
NSString *rewardMessage = [NSString
|
1799
|
+
stringWithFormat:
|
1800
|
+
@"Reward received with "
|
1801
|
+
@"currency %@ , amount %ld",
|
1802
|
+
reward
|
1803
|
+
.type,
|
1804
|
+
[reward.amount
|
1805
|
+
longValue]];
|
1806
|
+
NSLog (
|
1807
|
+
@"%"
|
1808
|
+
@"@",
|
1809
|
+
rewardMessage);
|
1810
|
+
}];
|
1811
|
+
pluginResult = [CDVPluginResult
|
1812
|
+
resultWithStatus:
|
1813
|
+
CDVCommandStatus_OK];
|
1814
|
+
}
|
1815
|
+
else
|
1816
|
+
{
|
1817
|
+
pluginResult = [CDVPluginResult
|
1818
|
+
resultWithStatus:
|
1819
|
+
CDVCommandStatus_ERROR];
|
1820
|
+
[self
|
1821
|
+
fireEvent:@""
|
1822
|
+
event:
|
1823
|
+
@"on."
|
1824
|
+
@"rewa"
|
1825
|
+
@"rded"
|
1826
|
+
@"Int."
|
1827
|
+
@"fail"
|
1828
|
+
@"ed."
|
1829
|
+
@"show"
|
1830
|
+
withData:nil];
|
1831
|
+
}
|
1832
|
+
[self.commandDelegate
|
1833
|
+
sendPluginResult:
|
1834
|
+
pluginResult
|
1835
|
+
callbackId:
|
1836
|
+
callbackId];
|
1837
|
+
}
|
1838
|
+
- (void)loadRewardedAd:
|
1839
|
+
(CDVInvokedUrlCommand
|
1840
|
+
*)command
|
1841
|
+
{
|
1842
|
+
CDVPluginResult
|
1843
|
+
*pluginResult;
|
1844
|
+
NSString *callbackId
|
1845
|
+
= command
|
1846
|
+
.callbackId;
|
1847
|
+
NSString *adUnitId =
|
1848
|
+
[command.arguments
|
1849
|
+
objectAtIndex:
|
1850
|
+
0];
|
1851
|
+
BOOL autoShow = [[command
|
1852
|
+
argumentAtIndex:
|
1853
|
+
1]
|
1854
|
+
boolValue];
|
1855
|
+
auto_Show = autoShow;
|
1856
|
+
adFormat = 3;
|
1857
|
+
if (adFormat == 3)
|
1858
|
+
{
|
1859
|
+
dispatch_async (
|
1860
|
+
dispatch_get_main_queue (),
|
1861
|
+
^{
|
1862
|
+
GADRequest
|
1863
|
+
*request
|
1864
|
+
= [GADRequest
|
1865
|
+
request];
|
1866
|
+
[GADRewardedAd loadWithAdUnitID:
|
1867
|
+
adUnitId
|
1868
|
+
request:
|
1869
|
+
request
|
1870
|
+
completionHandler:^(
|
1871
|
+
GADRewardedAd *ad, NSError
|
1872
|
+
*error) {
|
1873
|
+
if (error)
|
1874
|
+
{
|
1875
|
+
NSLog (
|
1876
|
+
@"Rewarded ad failed to load with error: %@",
|
1877
|
+
[error
|
1878
|
+
localizedDescription]);
|
1879
|
+
return;
|
1880
|
+
}
|
1881
|
+
self.rewardedAd
|
1882
|
+
= ad;
|
1883
|
+
NSLog (
|
1884
|
+
@"Rewarded ad loaded.");
|
1885
|
+
isAdSkip
|
1886
|
+
= 0;
|
1887
|
+
self.rewardedAd
|
1888
|
+
.fullScreenContentDelegate
|
1889
|
+
= self;
|
1890
|
+
[self
|
1891
|
+
fireEvent:
|
1892
|
+
@""
|
1893
|
+
event:
|
1894
|
+
@"on.rewarded.loaded"
|
1895
|
+
withData:
|
1896
|
+
nil];
|
1897
|
+
if (auto_Show)
|
1898
|
+
{
|
1899
|
+
if (self.rewardedAd
|
1900
|
+
&&
|
1901
|
+
[self.rewardedAd
|
1902
|
+
canPresentFromRootViewController:
|
1903
|
+
self.viewController
|
1904
|
+
error:
|
1905
|
+
nil])
|
1906
|
+
{
|
1907
|
+
[self.rewardedAd
|
1908
|
+
presentFromRootViewController:
|
1909
|
+
self.viewController
|
1910
|
+
userDidEarnRewardHandler:^{
|
1911
|
+
GADAdReward
|
1912
|
+
*reward
|
1913
|
+
= self.rewardedAd
|
1914
|
+
.adReward;
|
1915
|
+
[self
|
1916
|
+
fireEvent:
|
1917
|
+
@""
|
1918
|
+
event:
|
1919
|
+
@"on.reward.userEarnedReward"
|
1920
|
+
withData:
|
1921
|
+
nil];
|
1922
|
+
isAdSkip
|
1923
|
+
= 2;
|
1924
|
+
NSString
|
1925
|
+
*rewardMessage
|
1926
|
+
= [NSString
|
1927
|
+
stringWithFormat:
|
1928
|
+
@"Reward received with currency "
|
1929
|
+
@"%@ , amount %lf",
|
1930
|
+
reward
|
1931
|
+
.type,
|
1932
|
+
[reward.amount
|
1933
|
+
doubleValue]];
|
1934
|
+
NSLog (
|
1935
|
+
@"%@",
|
1936
|
+
rewardMessage);
|
1937
|
+
}];
|
1938
|
+
}
|
1939
|
+
else
|
1940
|
+
{
|
1941
|
+
[self
|
1942
|
+
fireEvent:
|
1943
|
+
@""
|
1944
|
+
event:
|
1945
|
+
@"on.rewarded.failed.show"
|
1946
|
+
withData:
|
1947
|
+
nil];
|
508
1948
|
}
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
1949
|
+
}
|
1950
|
+
}];
|
1951
|
+
});
|
1952
|
+
}
|
1953
|
+
pluginResult = [CDVPluginResult
|
1954
|
+
resultWithStatus:
|
1955
|
+
CDVCommandStatus_OK];
|
1956
|
+
[self.commandDelegate
|
1957
|
+
sendPluginResult:
|
1958
|
+
pluginResult
|
1959
|
+
callbackId:
|
1960
|
+
callbackId];
|
1961
|
+
}
|
1962
|
+
- (void)showRewardedAd:
|
1963
|
+
(CDVInvokedUrlCommand
|
1964
|
+
*)command
|
1965
|
+
{
|
1966
|
+
CDVPluginResult
|
1967
|
+
*pluginResult;
|
1968
|
+
NSString *callbackId
|
1969
|
+
= command
|
1970
|
+
.callbackId;
|
1971
|
+
if (self.rewardedAd
|
1972
|
+
&&
|
1973
|
+
[self.rewardedAd
|
1974
|
+
canPresentFromRootViewController:
|
1975
|
+
self.viewController
|
1976
|
+
error:
|
1977
|
+
nil])
|
1978
|
+
{
|
1979
|
+
[self.rewardedAd
|
1980
|
+
presentFromRootViewController:
|
1981
|
+
self.viewController
|
1982
|
+
userDidEarnRewardHandler:^{
|
1983
|
+
GADAdReward
|
1984
|
+
*reward
|
1985
|
+
= self.rewardedAd
|
1986
|
+
.adReward;
|
1987
|
+
[self
|
1988
|
+
fireEvent:
|
1989
|
+
@""
|
1990
|
+
event:
|
1991
|
+
@"on.reward.userEarnedReward"
|
1992
|
+
withData:
|
1993
|
+
nil];
|
1994
|
+
isAdSkip
|
1995
|
+
= 2;
|
1996
|
+
NSString *rewardMessage = [NSString
|
1997
|
+
stringWithFormat:
|
1998
|
+
@"Reward received with currency %@ , amount %lf",
|
1999
|
+
reward
|
2000
|
+
.type,
|
2001
|
+
[reward.amount
|
2002
|
+
doubleValue]];
|
2003
|
+
NSLog (
|
2004
|
+
@"%"
|
2005
|
+
@"@",
|
2006
|
+
rewardMessage);
|
2007
|
+
}];
|
2008
|
+
pluginResult = [CDVPluginResult
|
2009
|
+
resultWithStatus:
|
2010
|
+
CDVCommandStatus_OK];
|
2011
|
+
}
|
2012
|
+
else
|
2013
|
+
{
|
2014
|
+
pluginResult = [CDVPluginResult
|
2015
|
+
resultWithStatus:
|
2016
|
+
CDVCommandStatus_ERROR];
|
2017
|
+
[self
|
2018
|
+
fireEvent:@""
|
2019
|
+
event:
|
2020
|
+
@"on."
|
2021
|
+
@"rewa"
|
2022
|
+
@"rded"
|
2023
|
+
@".fai"
|
2024
|
+
@"led."
|
2025
|
+
@"show"
|
2026
|
+
withData:nil];
|
2027
|
+
}
|
2028
|
+
[self.commandDelegate
|
2029
|
+
sendPluginResult:
|
2030
|
+
pluginResult
|
2031
|
+
callbackId:
|
2032
|
+
callbackId];
|
2033
|
+
}
|
2034
|
+
- (void)
|
2035
|
+
fireEvent:
|
2036
|
+
(NSString *)
|
2037
|
+
obj
|
2038
|
+
event:
|
2039
|
+
(NSString
|
2040
|
+
*)
|
2041
|
+
eventName
|
2042
|
+
withData:
|
2043
|
+
(NSString *)
|
2044
|
+
jsonStr
|
2045
|
+
{
|
2046
|
+
NSString *js;
|
2047
|
+
if (obj &&
|
2048
|
+
[obj
|
2049
|
+
isEqualToString:
|
2050
|
+
@"windo"
|
2051
|
+
@"w"])
|
2052
|
+
{
|
2053
|
+
js = [NSString
|
2054
|
+
stringWithFormat:
|
2055
|
+
@"var "
|
2056
|
+
@"evt="
|
2057
|
+
@"document"
|
2058
|
+
@".createE"
|
2059
|
+
@"vent("
|
2060
|
+
@"\"UIEven"
|
2061
|
+
@"ts\");"
|
2062
|
+
@"evt."
|
2063
|
+
@"initUIEv"
|
2064
|
+
@"ent("
|
2065
|
+
@"\"%@\","
|
2066
|
+
@"true,"
|
2067
|
+
@"false,"
|
2068
|
+
@"window,"
|
2069
|
+
@"0);"
|
2070
|
+
@"window."
|
2071
|
+
@"dispatch"
|
2072
|
+
@"Event("
|
2073
|
+
@"evt);",
|
2074
|
+
eventName];
|
2075
|
+
}
|
2076
|
+
else if (jsonStr &&
|
2077
|
+
[jsonStr
|
2078
|
+
length]
|
2079
|
+
> 0)
|
2080
|
+
{
|
2081
|
+
js = [NSString
|
2082
|
+
stringWithFormat:
|
2083
|
+
@"javascri"
|
2084
|
+
@"pt:"
|
2085
|
+
@"cordova."
|
2086
|
+
@"fireDocu"
|
2087
|
+
@"mentEven"
|
2088
|
+
@"t('%@',%"
|
2089
|
+
@"@);",
|
2090
|
+
eventName,
|
2091
|
+
jsonStr];
|
2092
|
+
}
|
2093
|
+
else
|
2094
|
+
{
|
2095
|
+
js = [NSString
|
2096
|
+
stringWithFormat:
|
2097
|
+
@"javascri"
|
2098
|
+
@"pt:"
|
2099
|
+
@"cordova."
|
2100
|
+
@"fireDocu"
|
2101
|
+
@"mentEven"
|
2102
|
+
@"t('%@')"
|
2103
|
+
@";",
|
2104
|
+
eventName];
|
2105
|
+
}
|
2106
|
+
[self.commandDelegate
|
2107
|
+
evalJs:js];
|
2108
|
+
}
|
2109
|
+
|
2110
|
+
- (NSString *)
|
2111
|
+
__getAdMobDeviceId
|
2112
|
+
{
|
2113
|
+
NSUUID *adid = [[ASIdentifierManager
|
2114
|
+
sharedManager]
|
2115
|
+
advertisingIdentifier];
|
2116
|
+
return [self
|
2117
|
+
__md5:
|
2118
|
+
adid.UUIDString];
|
2119
|
+
}
|
2120
|
+
|
2121
|
+
- (NSString *)__md5:
|
2122
|
+
(NSString *)string
|
2123
|
+
{
|
2124
|
+
CC_MD5_CTX
|
2125
|
+
md5Context;
|
2126
|
+
CC_MD5_Init (
|
2127
|
+
&md5Context);
|
2128
|
+
NSData *data = [string
|
2129
|
+
dataUsingEncoding:
|
2130
|
+
NSUTF8StringEncoding];
|
2131
|
+
CC_MD5_Update (
|
2132
|
+
&md5Context,
|
2133
|
+
[data bytes],
|
2134
|
+
(CC_LONG)
|
2135
|
+
[data
|
2136
|
+
length]);
|
2137
|
+
unsigned char digest
|
2138
|
+
[CC_MD5_DIGEST_LENGTH];
|
2139
|
+
CC_MD5_Final (
|
2140
|
+
digest,
|
2141
|
+
&md5Context);
|
2142
|
+
|
2143
|
+
NSMutableString
|
2144
|
+
*hexString
|
2145
|
+
= [NSMutableString
|
2146
|
+
stringWithCapacity:
|
2147
|
+
(CC_MD5_DIGEST_LENGTH
|
2148
|
+
* 2)];
|
2149
|
+
for (
|
2150
|
+
int i = 0;
|
2151
|
+
i
|
2152
|
+
< CC_MD5_DIGEST_LENGTH;
|
2153
|
+
i++)
|
2154
|
+
{
|
2155
|
+
[hexString
|
2156
|
+
appendFormat:
|
2157
|
+
@"%02x",
|
2158
|
+
digest[i]];
|
2159
|
+
}
|
2160
|
+
|
2161
|
+
return hexString;
|
2162
|
+
}
|
2163
|
+
|
2164
|
+
#pragma mark \
|
2165
|
+
GADBannerViewDelegate implementation
|
2166
|
+
- (void)
|
2167
|
+
bannerViewDidReceiveAd:
|
2168
|
+
(GADBannerView
|
2169
|
+
*)
|
2170
|
+
bannerView
|
2171
|
+
{
|
2172
|
+
[self
|
2173
|
+
fireEvent:@""
|
2174
|
+
event:
|
2175
|
+
@"on."
|
2176
|
+
@"banner"
|
2177
|
+
@".load"
|
2178
|
+
withData:nil];
|
2179
|
+
NSLog (
|
2180
|
+
@"bannerViewDidR"
|
2181
|
+
@"eceiveAd");
|
2182
|
+
if (auto_Show)
|
2183
|
+
{
|
2184
|
+
if (self.bannerView)
|
2185
|
+
{
|
2186
|
+
[self
|
2187
|
+
addBannerViewToView:
|
2188
|
+
command];
|
2189
|
+
self.bannerView
|
2190
|
+
.hidden
|
2191
|
+
= NO;
|
2192
|
+
}
|
2193
|
+
}
|
2194
|
+
else
|
2195
|
+
{
|
2196
|
+
[self
|
2197
|
+
fireEvent:@""
|
2198
|
+
event:
|
2199
|
+
@"on."
|
2200
|
+
@"bann"
|
2201
|
+
@"er."
|
2202
|
+
@"fail"
|
2203
|
+
@"ed."
|
2204
|
+
@"show"
|
2205
|
+
withData:nil];
|
2206
|
+
}
|
2207
|
+
}
|
2208
|
+
- (void)bannerView:
|
2209
|
+
(GADBannerView
|
2210
|
+
*)
|
2211
|
+
bannerView
|
2212
|
+
didFailToReceiveAdWithError:
|
2213
|
+
(NSError *)
|
2214
|
+
error
|
2215
|
+
{
|
2216
|
+
[self
|
2217
|
+
fireEvent:@""
|
2218
|
+
event:
|
2219
|
+
@"on."
|
2220
|
+
@"banner"
|
2221
|
+
@".faile"
|
2222
|
+
@"d.load"
|
2223
|
+
withData:nil];
|
2224
|
+
NSLog (
|
2225
|
+
@"bannerView:"
|
2226
|
+
@"didFailToRecei"
|
2227
|
+
@"veAdWithError:"
|
2228
|
+
@" %@",
|
2229
|
+
[error
|
2230
|
+
localizedDescription]);
|
2231
|
+
}
|
2232
|
+
- (void)
|
2233
|
+
bannerViewDidRecordImpression:
|
2234
|
+
(GADBannerView
|
2235
|
+
*)
|
2236
|
+
bannerView
|
2237
|
+
{
|
2238
|
+
[self
|
2239
|
+
fireEvent:@""
|
2240
|
+
event:
|
2241
|
+
@"on."
|
2242
|
+
@"banner"
|
2243
|
+
@".impre"
|
2244
|
+
@"ssion"
|
2245
|
+
withData:nil];
|
2246
|
+
NSLog (@"bannerViewD"
|
2247
|
+
@"idRecordImp"
|
2248
|
+
@"ression");
|
2249
|
+
}
|
2250
|
+
- (void)
|
2251
|
+
bannerViewWillPresentScreen:
|
2252
|
+
(GADBannerView
|
2253
|
+
*)
|
2254
|
+
bannerView
|
2255
|
+
{
|
2256
|
+
[self
|
2257
|
+
fireEvent:@""
|
2258
|
+
event:
|
2259
|
+
@"on."
|
2260
|
+
@"banner"
|
2261
|
+
@".open"
|
2262
|
+
withData:nil];
|
2263
|
+
NSLog (@"bannerViewW"
|
2264
|
+
@"illPresentS"
|
2265
|
+
@"creen");
|
2266
|
+
}
|
2267
|
+
- (void)
|
2268
|
+
bannerViewWillDismissScreen:
|
2269
|
+
(GADBannerView
|
2270
|
+
*)
|
2271
|
+
bannerView
|
2272
|
+
{
|
2273
|
+
[self
|
2274
|
+
fireEvent:@""
|
2275
|
+
event:
|
2276
|
+
@"on."
|
2277
|
+
@"banner"
|
2278
|
+
@".close"
|
2279
|
+
withData:nil];
|
2280
|
+
NSLog (@"bannerViewW"
|
2281
|
+
@"illDismissS"
|
2282
|
+
@"creen");
|
2283
|
+
}
|
2284
|
+
- (void)
|
2285
|
+
bannerViewDidDismissScreen:
|
2286
|
+
(GADBannerView
|
2287
|
+
*)
|
2288
|
+
bannerView
|
2289
|
+
{
|
2290
|
+
[self
|
2291
|
+
fireEvent:@""
|
2292
|
+
event:
|
2293
|
+
@"on."
|
2294
|
+
@"banner"
|
2295
|
+
@".did."
|
2296
|
+
@"dismis"
|
2297
|
+
@"s"
|
2298
|
+
withData:nil];
|
2299
|
+
NSLog (
|
2300
|
+
@"bannerViewDidD"
|
2301
|
+
@"ismissScreen");
|
2302
|
+
}
|
2303
|
+
#pragma GADFullScreeContentDelegate \
|
2304
|
+
implementation
|
2305
|
+
- (void)
|
2306
|
+
adWillPresentFullScreenContent:
|
2307
|
+
(id)ad
|
2308
|
+
{
|
2309
|
+
if (adFormat == 1)
|
2310
|
+
{
|
2311
|
+
[self
|
2312
|
+
fireEvent:@""
|
2313
|
+
event:
|
2314
|
+
@"on."
|
2315
|
+
@"appO"
|
2316
|
+
@"penA"
|
2317
|
+
@"d."
|
2318
|
+
@"show"
|
2319
|
+
withData:nil];
|
2320
|
+
NSLog (
|
2321
|
+
@"Ad will "
|
2322
|
+
@"present "
|
2323
|
+
@"full screen "
|
2324
|
+
@"content App "
|
2325
|
+
@"Open Ad.");
|
2326
|
+
}
|
2327
|
+
else if (adFormat
|
2328
|
+
== 2)
|
2329
|
+
{
|
2330
|
+
[self
|
2331
|
+
fireEvent:@""
|
2332
|
+
event:
|
2333
|
+
@"on."
|
2334
|
+
@"inte"
|
2335
|
+
@"rsti"
|
2336
|
+
@"tial"
|
2337
|
+
@".sho"
|
2338
|
+
@"w"
|
2339
|
+
withData:nil];
|
2340
|
+
[self
|
2341
|
+
fireEvent:@""
|
2342
|
+
event:
|
2343
|
+
@"onPr"
|
2344
|
+
@"esen"
|
2345
|
+
@"tAd"
|
2346
|
+
withData:nil];
|
2347
|
+
NSLog (
|
2348
|
+
@"Ad will "
|
2349
|
+
@"present "
|
2350
|
+
@"full screen "
|
2351
|
+
@"content "
|
2352
|
+
@"interstitial"
|
2353
|
+
@".");
|
2354
|
+
}
|
2355
|
+
else if (adFormat
|
2356
|
+
== 3)
|
2357
|
+
{
|
2358
|
+
[self
|
2359
|
+
fireEvent:@""
|
2360
|
+
event:
|
2361
|
+
@"on."
|
2362
|
+
@"rewa"
|
2363
|
+
@"rded"
|
2364
|
+
@".sho"
|
2365
|
+
@"w"
|
2366
|
+
withData:nil];
|
2367
|
+
isAdSkip = 1;
|
2368
|
+
NSLog (
|
2369
|
+
@"Ad will "
|
2370
|
+
@"present "
|
2371
|
+
@"full screen "
|
2372
|
+
@"content "
|
2373
|
+
@"rewarded.");
|
2374
|
+
}
|
2375
|
+
else if (adFormat
|
2376
|
+
== 4)
|
2377
|
+
{
|
2378
|
+
isAdSkip = 1;
|
2379
|
+
[self
|
2380
|
+
fireEvent:@""
|
2381
|
+
event:
|
2382
|
+
@"on."
|
2383
|
+
@"rewa"
|
2384
|
+
@"rded"
|
2385
|
+
@"Int."
|
2386
|
+
@"show"
|
2387
|
+
@"ed"
|
2388
|
+
withData:nil];
|
2389
|
+
NSLog (
|
2390
|
+
@"Ad will "
|
2391
|
+
@"present "
|
2392
|
+
@"full screen "
|
2393
|
+
@"content "
|
2394
|
+
@"interstitial"
|
2395
|
+
@" rewarded.");
|
2396
|
+
}
|
2397
|
+
}
|
2398
|
+
- (void)ad:(id)ad
|
2399
|
+
didFailToPresentFullScreenContentWithError:
|
2400
|
+
(NSError *)
|
2401
|
+
error
|
2402
|
+
{
|
2403
|
+
if (adFormat == 1)
|
2404
|
+
{
|
2405
|
+
[self
|
2406
|
+
fireEvent:@""
|
2407
|
+
event:
|
2408
|
+
@"on."
|
2409
|
+
@"appO"
|
2410
|
+
@"penA"
|
2411
|
+
@"d."
|
2412
|
+
@"fail"
|
2413
|
+
@"ed."
|
2414
|
+
@"load"
|
2415
|
+
@"ed"
|
2416
|
+
withData:nil];
|
2417
|
+
NSLog (
|
2418
|
+
@"Ad failed "
|
2419
|
+
@"to present "
|
2420
|
+
@"full screen "
|
2421
|
+
@"content "
|
2422
|
+
@"with error "
|
2423
|
+
@"App Open Ad "
|
2424
|
+
@"%@.",
|
2425
|
+
[error
|
2426
|
+
localizedDescription]);
|
2427
|
+
}
|
2428
|
+
else if (adFormat
|
2429
|
+
== 2)
|
2430
|
+
{
|
2431
|
+
[self
|
2432
|
+
fireEvent:@""
|
2433
|
+
event:
|
2434
|
+
@"on."
|
2435
|
+
@"inte"
|
2436
|
+
@"rsti"
|
2437
|
+
@"tial"
|
2438
|
+
@".fai"
|
2439
|
+
@"led."
|
2440
|
+
@"load"
|
2441
|
+
withData:nil];
|
2442
|
+
NSLog (
|
2443
|
+
@"Ad failed "
|
2444
|
+
@"to present "
|
2445
|
+
@"full screen "
|
2446
|
+
@"content "
|
2447
|
+
@"with error "
|
2448
|
+
@"interstitial"
|
2449
|
+
@" %@.",
|
2450
|
+
[error
|
2451
|
+
localizedDescription]);
|
2452
|
+
}
|
2453
|
+
else if (adFormat
|
2454
|
+
== 3)
|
2455
|
+
{
|
2456
|
+
[self
|
2457
|
+
fireEvent:@""
|
2458
|
+
event:
|
2459
|
+
@"on."
|
2460
|
+
@"rewa"
|
2461
|
+
@"rded"
|
2462
|
+
@".fai"
|
2463
|
+
@"led."
|
2464
|
+
@"load"
|
2465
|
+
withData:nil];
|
2466
|
+
NSLog (
|
2467
|
+
@"Ad failed "
|
2468
|
+
@"to present "
|
2469
|
+
@"full screen "
|
2470
|
+
@"content "
|
2471
|
+
@"with error "
|
2472
|
+
@"rewarded "
|
2473
|
+
@"%@.",
|
2474
|
+
[error
|
2475
|
+
localizedDescription]);
|
2476
|
+
}
|
2477
|
+
else if (adFormat
|
2478
|
+
== 4)
|
2479
|
+
{
|
2480
|
+
[self
|
2481
|
+
fireEvent:@""
|
2482
|
+
event:
|
2483
|
+
@"on."
|
2484
|
+
@"rewa"
|
2485
|
+
@"rded"
|
2486
|
+
@"Int."
|
2487
|
+
@"fail"
|
2488
|
+
@"ed."
|
2489
|
+
@"load"
|
2490
|
+
withData:nil];
|
2491
|
+
NSLog (
|
2492
|
+
@"Ad failed "
|
2493
|
+
@"to present "
|
2494
|
+
@"full screen "
|
2495
|
+
@"content "
|
2496
|
+
@"with error "
|
2497
|
+
@"interstitial"
|
2498
|
+
@" "
|
2499
|
+
@"rewarded "
|
2500
|
+
@"%@.",
|
2501
|
+
[error
|
2502
|
+
localizedDescription]);
|
2503
|
+
}
|
2504
|
+
}
|
2505
|
+
- (void)
|
2506
|
+
adDidDismissFullScreenContent:
|
2507
|
+
(id)ad
|
2508
|
+
{
|
2509
|
+
if (adFormat == 1)
|
2510
|
+
{
|
2511
|
+
[self
|
2512
|
+
fireEvent:@""
|
2513
|
+
event:
|
2514
|
+
@"on."
|
2515
|
+
@"appO"
|
2516
|
+
@"penA"
|
2517
|
+
@"d."
|
2518
|
+
@"dism"
|
2519
|
+
@"isse"
|
2520
|
+
@"d"
|
2521
|
+
withData:nil];
|
2522
|
+
NSLog (
|
2523
|
+
@"Ad did "
|
2524
|
+
@"dismiss "
|
2525
|
+
@"full screen "
|
2526
|
+
@"content App "
|
2527
|
+
@"Open Ad.");
|
2528
|
+
}
|
2529
|
+
else if (adFormat
|
2530
|
+
== 2)
|
2531
|
+
{
|
2532
|
+
[self
|
2533
|
+
fireEvent:@""
|
2534
|
+
event:
|
2535
|
+
@"on."
|
2536
|
+
@"inte"
|
2537
|
+
@"rsti"
|
2538
|
+
@"tial"
|
2539
|
+
@".dis"
|
2540
|
+
@"miss"
|
2541
|
+
@"ed"
|
2542
|
+
withData:nil];
|
2543
|
+
NSLog (
|
2544
|
+
@"Ad did "
|
2545
|
+
@"dismiss "
|
2546
|
+
@"full screen "
|
2547
|
+
@"content "
|
2548
|
+
@"interstitial"
|
2549
|
+
@".");
|
2550
|
+
}
|
2551
|
+
else if (adFormat
|
2552
|
+
== 3)
|
2553
|
+
{
|
2554
|
+
[self
|
2555
|
+
fireEvent:@""
|
2556
|
+
event:
|
2557
|
+
@"on."
|
2558
|
+
@"rewa"
|
2559
|
+
@"rded"
|
2560
|
+
@".dis"
|
2561
|
+
@"miss"
|
2562
|
+
@"ed"
|
2563
|
+
withData:nil];
|
2564
|
+
if (isAdSkip != 2)
|
2565
|
+
{
|
2566
|
+
[self
|
2567
|
+
fireEvent:@""
|
2568
|
+
event:
|
2569
|
+
@"on"
|
2570
|
+
@".r"
|
2571
|
+
@"ew"
|
2572
|
+
@"ar"
|
2573
|
+
@"de"
|
2574
|
+
@"d."
|
2575
|
+
@"ad"
|
2576
|
+
@".s"
|
2577
|
+
@"ki"
|
2578
|
+
@"p"
|
2579
|
+
withData:
|
2580
|
+
nil];
|
2581
|
+
}
|
2582
|
+
NSLog (
|
2583
|
+
@"Ad did "
|
2584
|
+
@"dismiss "
|
2585
|
+
@"full screen "
|
2586
|
+
@"content "
|
2587
|
+
@"rewarded.");
|
2588
|
+
}
|
2589
|
+
else if (adFormat
|
2590
|
+
== 4)
|
2591
|
+
{
|
2592
|
+
if (isAdSkip != 2)
|
2593
|
+
{
|
2594
|
+
[self
|
2595
|
+
fireEvent:@""
|
2596
|
+
event:
|
2597
|
+
@"on"
|
2598
|
+
@".r"
|
2599
|
+
@"ew"
|
2600
|
+
@"ar"
|
2601
|
+
@"de"
|
2602
|
+
@"dI"
|
2603
|
+
@"nt"
|
2604
|
+
@".a"
|
2605
|
+
@"d."
|
2606
|
+
@"sk"
|
2607
|
+
@"ip"
|
2608
|
+
withData:
|
2609
|
+
nil];
|
2610
|
+
}
|
2611
|
+
[self
|
2612
|
+
fireEvent:@""
|
2613
|
+
event:
|
2614
|
+
@"on."
|
2615
|
+
@"rewa"
|
2616
|
+
@"rded"
|
2617
|
+
@"Int."
|
2618
|
+
@"dism"
|
2619
|
+
@"isse"
|
2620
|
+
@"d"
|
2621
|
+
withData:nil];
|
2622
|
+
NSLog (
|
2623
|
+
@"Ad did "
|
2624
|
+
@"dismiss "
|
2625
|
+
@"full screen "
|
2626
|
+
@"content "
|
2627
|
+
@"interstitial"
|
2628
|
+
@" rewarded.");
|
2629
|
+
}
|
2630
|
+
}
|
515
2631
|
#pragma mark Cleanup
|
516
|
-
- (void)dealloc
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
2632
|
+
- (void)dealloc
|
2633
|
+
{
|
2634
|
+
self.appOpenAd = nil;
|
2635
|
+
self.bannerView
|
2636
|
+
= nil;
|
2637
|
+
self.interstitial
|
2638
|
+
= nil;
|
2639
|
+
self.rewardedAd
|
2640
|
+
= nil;
|
2641
|
+
self.rewardedInterstitialAd
|
2642
|
+
= nil;
|
522
2643
|
}
|
523
2644
|
@end
|