emi-indo-cordova-plugin-admob 1.5.1 → 1.5.2
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/.vscode/settings.json +7 -0
- package/README.md +26 -5
- package/package.json +1 -1
- package/plugin.xml +11 -8
- package/src/ios/emiAdmobPlugin.h +1 -1
- package/src/ios/emiAdmobPlugin.m +1600 -1545
package/src/ios/emiAdmobPlugin.m
CHANGED
@@ -14,13 +14,13 @@
|
|
14
14
|
@synthesize responseInfo;
|
15
15
|
@synthesize isPrivacyOptionsRequired;
|
16
16
|
int idfaStatus = 0;
|
17
|
-
int fromStatus = 0; // Deprecated
|
17
|
+
// int fromStatus = 0; // Deprecated
|
18
18
|
int Consent_Status = 0;
|
19
19
|
int adFormat = 0;
|
20
|
-
int adWidth = 320; //
|
20
|
+
int adWidth = 320; // Default
|
21
21
|
BOOL auto_Show = NO;
|
22
22
|
// NSString *Npa = @"1"; // Deprecated
|
23
|
-
NSString *Position = @"bottom";
|
23
|
+
NSString *Position = @"bottom"; // Default
|
24
24
|
NSString *bannerSaveAdUnitId = @""; // autoResize dependency = true
|
25
25
|
|
26
26
|
BOOL enableCollapsible = NO;
|
@@ -35,1696 +35,1751 @@ BOOL ResponseInfo = NO;
|
|
35
35
|
BOOL isUsingAdManagerRequest = YES;
|
36
36
|
|
37
37
|
- (BOOL)canRequestAds {
|
38
|
-
|
38
|
+
return UMPConsentInformation.sharedInstance.canRequestAds;
|
39
39
|
}
|
40
40
|
- (void)setUsingAdManagerRequest:(BOOL)value {
|
41
|
-
|
41
|
+
isUsingAdManagerRequest = value;
|
42
42
|
}
|
43
43
|
- (void)ResponseInfo:(BOOL)value {
|
44
|
-
|
44
|
+
ResponseInfo = value;
|
45
45
|
}
|
46
46
|
- (void)isDebugGeography:(BOOL)value {
|
47
|
-
|
47
|
+
isDebugGeography = value;
|
48
48
|
}
|
49
49
|
|
50
50
|
- (void)initialize:(CDVInvokedUrlCommand *)command {
|
51
|
-
|
52
|
-
NSDictionary *options = [command.arguments objectAtIndex:0];
|
53
|
-
|
54
|
-
BOOL setAdRequest = [[options valueForKey:@"isUsingAdManagerRequest"] boolValue];
|
55
|
-
BOOL responseInfo = [[options valueForKey:@"isResponseInfo"] boolValue];
|
56
|
-
BOOL setDebugGeography = [[options valueForKey:@"isConsentDebug"] boolValue];
|
57
|
-
|
58
|
-
[self setUsingAdManagerRequest:setAdRequest];
|
59
|
-
[self ResponseInfo:responseInfo];
|
60
|
-
[self isDebugGeography:setDebugGeography];
|
61
|
-
|
62
|
-
__block CDVPluginResult *pluginResult;
|
63
|
-
NSString *callbackId = command.callbackId;
|
64
|
-
NSString *deviceId = [self __getAdMobDeviceId];
|
65
|
-
UMPRequestParameters *parameters = [[UMPRequestParameters alloc] init];
|
66
|
-
|
67
|
-
if (isDebugGeography) {
|
68
|
-
UMPDebugSettings *debugSettings = [[UMPDebugSettings alloc] init];
|
69
|
-
parameters.debugSettings = debugSettings;
|
70
|
-
debugSettings.geography = UMPDebugGeographyEEA;
|
71
|
-
debugSettings.testDeviceIdentifiers = @[ deviceId ];
|
72
|
-
}
|
73
|
-
|
74
|
-
parameters.tagForUnderAgeOfConsent = UnderAgeOfConsent;
|
75
|
-
|
76
|
-
dispatch_async(dispatch_get_main_queue(), ^{
|
77
|
-
// Request consent info update
|
78
|
-
[UMPConsentInformation.sharedInstance
|
79
|
-
requestConsentInfoUpdateWithParameters:parameters
|
80
|
-
completionHandler:^(NSError *_Nullable requestConsentError) {
|
81
|
-
if (requestConsentError) {
|
82
|
-
// NSLog(@"Request consent error: %@", requestConsentError.localizedDescription);
|
83
|
-
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:requestConsentError.description];
|
84
|
-
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
85
|
-
return;
|
86
|
-
}
|
87
|
-
|
88
|
-
// Check the consent status after update
|
89
|
-
UMPConsentStatus status = UMPConsentInformation.sharedInstance.consentStatus;
|
90
|
-
// NSLog(@"Consent status: %ld", (long)status);
|
91
|
-
|
92
|
-
// Handle consent status
|
93
|
-
if (status == UMPConsentStatusRequired) {
|
94
|
-
// If consent is required, load and display consent form
|
95
|
-
[UMPConsentForm loadWithCompletionHandler:^(UMPConsentForm *form, NSError *loadError) {
|
96
|
-
if (loadError) {
|
97
|
-
// NSLog(@"Load consent form error: %@", loadError.localizedDescription);
|
98
|
-
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:loadError.description];
|
99
|
-
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
100
|
-
} else {
|
101
|
-
// Present the consent form to the user
|
102
|
-
[form presentFromViewController:[UIApplication sharedApplication].delegate.window.rootViewController
|
103
|
-
completionHandler:^(NSError *_Nullable dismissError) {
|
104
|
-
if (dismissError) {
|
105
|
-
// NSLog(@"Dismiss consent form error: %@", dismissError.localizedDescription);
|
106
|
-
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:dismissError.description];
|
107
|
-
} else {
|
108
|
-
// NSLog(@"Consent form successfully presented.");
|
109
|
-
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:@"Consent form displayed successfully."];
|
110
|
-
}
|
111
|
-
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
112
|
-
}];
|
113
|
-
}
|
114
|
-
|
115
|
-
|
116
|
-
if (UMPConsentInformation.sharedInstance.canRequestAds) {
|
117
|
-
[self startGoogleMobileAdsSDK];
|
118
|
-
}
|
119
|
-
|
120
|
-
|
121
|
-
}];
|
122
|
-
} else if (status == UMPConsentStatusNotRequired || status == UMPConsentStatusObtained) {
|
123
|
-
// If consent is not required or already obtained, start the ads SDK
|
124
|
-
if (UMPConsentInformation.sharedInstance.canRequestAds) {
|
125
|
-
[self startGoogleMobileAdsSDK];
|
126
|
-
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:@"Ads SDK started."];
|
127
|
-
} else {
|
128
|
-
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Cannot request ads, consent is required."];
|
129
|
-
}
|
130
|
-
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
131
|
-
} else {
|
132
|
-
// NSLog(@"Consent status unknown or error.");
|
133
|
-
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Consent status unknown."];
|
134
|
-
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
135
|
-
}
|
136
|
-
}];
|
137
|
-
});
|
138
|
-
}
|
139
|
-
|
140
51
|
|
52
|
+
NSDictionary *options = [command.arguments objectAtIndex:0];
|
53
|
+
|
54
|
+
BOOL setAdRequest =
|
55
|
+
[[options valueForKey:@"isUsingAdManagerRequest"] boolValue];
|
56
|
+
BOOL responseInfo = [[options valueForKey:@"isResponseInfo"] boolValue];
|
57
|
+
BOOL setDebugGeography = [[options valueForKey:@"isConsentDebug"] boolValue];
|
58
|
+
|
59
|
+
[self setUsingAdManagerRequest:setAdRequest];
|
60
|
+
[self ResponseInfo:responseInfo];
|
61
|
+
[self isDebugGeography:setDebugGeography];
|
62
|
+
|
63
|
+
__block CDVPluginResult *pluginResult;
|
64
|
+
NSString *callbackId = command.callbackId;
|
65
|
+
NSString *deviceId = [self __getAdMobDeviceId];
|
66
|
+
UMPRequestParameters *parameters = [[UMPRequestParameters alloc] init];
|
67
|
+
|
68
|
+
if (isDebugGeography) {
|
69
|
+
UMPDebugSettings *debugSettings = [[UMPDebugSettings alloc] init];
|
70
|
+
parameters.debugSettings = debugSettings;
|
71
|
+
debugSettings.geography = UMPDebugGeographyEEA;
|
72
|
+
debugSettings.testDeviceIdentifiers = @[ deviceId ];
|
73
|
+
}
|
74
|
+
|
75
|
+
parameters.tagForUnderAgeOfConsent = UnderAgeOfConsent;
|
76
|
+
|
77
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
78
|
+
// Request consent info update
|
79
|
+
[UMPConsentInformation.sharedInstance
|
80
|
+
requestConsentInfoUpdateWithParameters:parameters
|
81
|
+
completionHandler:^(
|
82
|
+
NSError *_Nullable requestConsentError) {
|
83
|
+
if (requestConsentError) {
|
84
|
+
// NSLog(@"Request consent error: %@",
|
85
|
+
// requestConsentError.localizedDescription);
|
86
|
+
pluginResult = [CDVPluginResult
|
87
|
+
resultWithStatus:CDVCommandStatus_ERROR
|
88
|
+
messageAsString:requestConsentError
|
89
|
+
.description];
|
90
|
+
[self.commandDelegate
|
91
|
+
sendPluginResult:pluginResult
|
92
|
+
callbackId:callbackId];
|
93
|
+
return;
|
94
|
+
}
|
95
|
+
|
96
|
+
// Check the consent status after update
|
97
|
+
UMPConsentStatus status =
|
98
|
+
UMPConsentInformation.sharedInstance
|
99
|
+
.consentStatus;
|
100
|
+
// NSLog(@"Consent status: %ld", (long)status);
|
101
|
+
|
102
|
+
// Handle consent status
|
103
|
+
if (status == UMPConsentStatusRequired) {
|
104
|
+
// If consent is required, load and display
|
105
|
+
// consent form
|
106
|
+
[UMPConsentForm loadWithCompletionHandler:^(
|
107
|
+
UMPConsentForm *form,
|
108
|
+
NSError *loadError) {
|
109
|
+
if (loadError) {
|
110
|
+
// NSLog(@"Load consent form error: %@",
|
111
|
+
// loadError.localizedDescription);
|
112
|
+
pluginResult = [CDVPluginResult
|
113
|
+
resultWithStatus:CDVCommandStatus_ERROR
|
114
|
+
messageAsString:loadError
|
115
|
+
.description];
|
116
|
+
[self.commandDelegate
|
117
|
+
sendPluginResult:pluginResult
|
118
|
+
callbackId:callbackId];
|
119
|
+
} else {
|
120
|
+
// Present the consent form to the user
|
121
|
+
[form
|
122
|
+
presentFromViewController:
|
123
|
+
[UIApplication sharedApplication]
|
124
|
+
.delegate.window
|
125
|
+
.rootViewController
|
126
|
+
completionHandler:^(
|
127
|
+
NSError
|
128
|
+
*_Nullable dismissError) {
|
129
|
+
if (dismissError) {
|
130
|
+
// NSLog(@"Dismiss consent
|
131
|
+
// form error: %@",
|
132
|
+
// dismissError.localizedDescription);
|
133
|
+
pluginResult = [CDVPluginResult
|
134
|
+
resultWithStatus:
|
135
|
+
CDVCommandStatus_ERROR
|
136
|
+
messageAsString:
|
137
|
+
dismissError
|
138
|
+
.description];
|
139
|
+
} else {
|
140
|
+
// NSLog(@"Consent form
|
141
|
+
// successfully
|
142
|
+
// presented.");
|
143
|
+
pluginResult = [CDVPluginResult
|
144
|
+
resultWithStatus:
|
145
|
+
CDVCommandStatus_OK
|
146
|
+
messageAsString:
|
147
|
+
@"Consent form "
|
148
|
+
@"displayed "
|
149
|
+
@"successfully."];
|
150
|
+
}
|
151
|
+
[self.commandDelegate
|
152
|
+
sendPluginResult:
|
153
|
+
pluginResult
|
154
|
+
callbackId:
|
155
|
+
callbackId];
|
156
|
+
}];
|
157
|
+
}
|
158
|
+
|
159
|
+
if (UMPConsentInformation.sharedInstance
|
160
|
+
.canRequestAds) {
|
161
|
+
[self startGoogleMobileAdsSDK];
|
162
|
+
}
|
163
|
+
}];
|
164
|
+
} else if (status ==
|
165
|
+
UMPConsentStatusNotRequired ||
|
166
|
+
status == UMPConsentStatusObtained) {
|
167
|
+
// If consent is not required or already
|
168
|
+
// obtained, start the ads SDK
|
169
|
+
if (UMPConsentInformation.sharedInstance
|
170
|
+
.canRequestAds) {
|
171
|
+
[self startGoogleMobileAdsSDK];
|
172
|
+
pluginResult = [CDVPluginResult
|
173
|
+
resultWithStatus:CDVCommandStatus_OK
|
174
|
+
messageAsString:@"Ads SDK started."];
|
175
|
+
} else {
|
176
|
+
pluginResult = [CDVPluginResult
|
177
|
+
resultWithStatus:CDVCommandStatus_ERROR
|
178
|
+
messageAsString:
|
179
|
+
@"Cannot request ads, consent is "
|
180
|
+
@"required."];
|
181
|
+
}
|
182
|
+
[self.commandDelegate
|
183
|
+
sendPluginResult:pluginResult
|
184
|
+
callbackId:callbackId];
|
185
|
+
} else {
|
186
|
+
// NSLog(@"Consent status unknown or error.");
|
187
|
+
pluginResult = [CDVPluginResult
|
188
|
+
resultWithStatus:CDVCommandStatus_ERROR
|
189
|
+
messageAsString:
|
190
|
+
@"Consent status unknown."];
|
191
|
+
[self.commandDelegate
|
192
|
+
sendPluginResult:pluginResult
|
193
|
+
callbackId:callbackId];
|
194
|
+
}
|
195
|
+
}];
|
196
|
+
});
|
197
|
+
}
|
141
198
|
|
142
199
|
- (void)requestIDFA:(CDVInvokedUrlCommand *)command {
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
withData:nil];
|
182
|
-
pluginResult =
|
183
|
-
[CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
|
184
|
-
}
|
185
|
-
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
200
|
+
CDVPluginResult *pluginResult;
|
201
|
+
NSString *callbackId = command.callbackId;
|
202
|
+
if (@available(iOS 14, *)) {
|
203
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
204
|
+
[ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(
|
205
|
+
ATTrackingManagerAuthorizationStatus status) {
|
206
|
+
if (status == ATTrackingManagerAuthorizationStatusDenied) {
|
207
|
+
idfaStatus = ATTrackingManagerAuthorizationStatusDenied;
|
208
|
+
} else if (status == ATTrackingManagerAuthorizationStatusAuthorized) {
|
209
|
+
idfaStatus = ATTrackingManagerAuthorizationStatusAuthorized;
|
210
|
+
} else if (status == ATTrackingManagerAuthorizationStatusRestricted) {
|
211
|
+
idfaStatus = ATTrackingManagerAuthorizationStatusRestricted;
|
212
|
+
} else if (status ==
|
213
|
+
ATTrackingManagerAuthorizationStatusNotDetermined) {
|
214
|
+
idfaStatus = ATTrackingManagerAuthorizationStatusNotDetermined;
|
215
|
+
}
|
216
|
+
}];
|
217
|
+
});
|
218
|
+
[self fireEvent:@""
|
219
|
+
event:@"on."
|
220
|
+
@"getI"
|
221
|
+
@"DFA."
|
222
|
+
@"stat"
|
223
|
+
@"us"
|
224
|
+
withData:nil];
|
225
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK
|
226
|
+
messageAsInt:idfaStatus];
|
227
|
+
} else {
|
228
|
+
[self fireEvent:@""
|
229
|
+
event:@"on."
|
230
|
+
@"getI"
|
231
|
+
@"DFA."
|
232
|
+
@"erro"
|
233
|
+
@"r"
|
234
|
+
withData:nil];
|
235
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
|
236
|
+
}
|
237
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
186
238
|
}
|
187
|
-
|
239
|
+
/*
|
188
240
|
- (void)getConsentRequest:(CDVInvokedUrlCommand *)command {
|
189
|
-
|
190
241
|
}
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
242
|
+
*/
|
199
243
|
- (void)startGoogleMobileAdsSDK {
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
244
|
+
static dispatch_once_t onceToken;
|
245
|
+
dispatch_once(&onceToken, ^{
|
246
|
+
// Initialize the Google Mobile Ads SDK.
|
247
|
+
GADMobileAds *ads = [GADMobileAds sharedInstance];
|
248
|
+
[ads startWithCompletionHandler:^(GADInitializationStatus *status) {
|
249
|
+
NSDictionary *adapterStatuses = [status adapterStatusesByClassName];
|
250
|
+
NSMutableArray *adaptersArray = [NSMutableArray array];
|
251
|
+
|
252
|
+
for (NSString *adapter in adapterStatuses) {
|
253
|
+
GADAdapterStatus *adapterStatus = adapterStatuses[adapter];
|
254
|
+
NSLog(@"Adapter Name: %@, Description: %@, Latency: %f", adapter,
|
255
|
+
adapterStatus.description, adapterStatus.latency);
|
256
|
+
|
257
|
+
NSDictionary *adapterInfo = @{@"name" : adapter};
|
258
|
+
|
259
|
+
[adaptersArray addObject:adapterInfo];
|
260
|
+
}
|
261
|
+
|
262
|
+
NSString *sdkVersion = GADGetStringFromVersionNumber(
|
263
|
+
GADMobileAds.sharedInstance.versionNumber);
|
264
|
+
int Consent_Status =
|
265
|
+
(int)UMPConsentInformation.sharedInstance.consentStatus;
|
266
|
+
|
267
|
+
NSMutableDictionary *result = [[NSMutableDictionary alloc] init];
|
268
|
+
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
|
269
|
+
NSNumber *CmpSdkID = [prefs valueForKey:@"IABTCF_CmpSdkID"];
|
270
|
+
NSString *gdprApplies = [prefs stringForKey:@"IABTCF_gdprApplies"];
|
271
|
+
NSString *PurposeConsents =
|
272
|
+
[prefs stringForKey:@"IABTCF_PurposeConsents"];
|
273
|
+
NSString *TCString = [prefs stringForKey:@"IABTCF_TCString"];
|
274
|
+
NSString *additionalConsent = [prefs stringForKey:@"IABTCF_AddtlConsent"];
|
275
|
+
|
276
|
+
result[@"version"] = sdkVersion;
|
277
|
+
result[@"consentStatus"] = @(Consent_Status);
|
278
|
+
result[@"adapter"] = adaptersArray;
|
279
|
+
result[@"CmpSdkID"] = CmpSdkID;
|
280
|
+
result[@"gdprApplies"] = gdprApplies;
|
281
|
+
result[@"PurposeConsents"] = PurposeConsents;
|
282
|
+
result[@"TCString"] = TCString;
|
283
|
+
result[@"additionalConsent"] = additionalConsent;
|
284
|
+
|
285
|
+
// NSLog(@"Result dictionary: %@", result);consentStatus
|
286
|
+
|
287
|
+
NSError *error;
|
288
|
+
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:result
|
289
|
+
options:0
|
290
|
+
error:&error];
|
291
|
+
|
292
|
+
if (!jsonData) {
|
293
|
+
NSLog(@"Error converting result to JSON: %@",
|
294
|
+
error.localizedDescription);
|
295
|
+
} else {
|
296
|
+
NSString *jsonString =
|
297
|
+
[[NSString alloc] initWithData:jsonData
|
298
|
+
encoding:NSUTF8StringEncoding];
|
299
|
+
|
300
|
+
// NSLog(@"JSON String: %@", jsonString);
|
301
|
+
|
302
|
+
[self fireEvent:@"" event:@"on.sdkInitialization" withData:jsonString];
|
303
|
+
}
|
304
|
+
|
305
|
+
[prefs synchronize];
|
306
|
+
}];
|
307
|
+
});
|
258
308
|
}
|
259
309
|
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
310
|
- (void)forceDisplayPrivacyForm:(CDVInvokedUrlCommand *)command {
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
311
|
+
NSString *deviceId = [self __getAdMobDeviceId];
|
312
|
+
UMPRequestParameters *parameters = [[UMPRequestParameters alloc] init];
|
313
|
+
|
314
|
+
if (isDebugGeography) {
|
315
|
+
UMPDebugSettings *debugSettings = [[UMPDebugSettings alloc] init];
|
316
|
+
debugSettings.geography = UMPDebugGeographyEEA;
|
317
|
+
debugSettings.testDeviceIdentifiers = @[ deviceId ];
|
318
|
+
parameters.debugSettings = debugSettings;
|
319
|
+
}
|
320
|
+
|
321
|
+
parameters.tagForUnderAgeOfConsent = UnderAgeOfConsent;
|
322
|
+
|
323
|
+
// [UMPConsentInformation.sharedInstance reset];
|
324
|
+
|
325
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
326
|
+
[UMPConsentInformation.sharedInstance requestConsentInfoUpdateWithParameters:
|
327
|
+
parameters
|
328
|
+
completionHandler:^(
|
329
|
+
NSError
|
330
|
+
*_Nullable requestConsentError) {
|
331
|
+
if (requestConsentError !=
|
332
|
+
nil) {
|
333
|
+
// NSLog(@"Errors
|
334
|
+
// in
|
335
|
+
// updating
|
336
|
+
// consent
|
337
|
+
// information:
|
338
|
+
// %@",
|
339
|
+
// requestConsentError);
|
340
|
+
CDVPluginResult
|
341
|
+
*pluginResult = [CDVPluginResult
|
342
|
+
resultWithStatus:
|
343
|
+
CDVCommandStatus_ERROR
|
344
|
+
messageAsString:
|
345
|
+
requestConsentError
|
346
|
+
.description];
|
347
|
+
[self.commandDelegate
|
348
|
+
sendPluginResult:
|
349
|
+
pluginResult
|
350
|
+
callbackId:
|
351
|
+
command
|
352
|
+
.callbackId];
|
353
|
+
return;
|
354
|
+
}
|
355
|
+
|
356
|
+
// NSLog(@"Successful
|
357
|
+
// update of
|
358
|
+
// consent
|
359
|
+
// info.
|
360
|
+
// Continue to
|
361
|
+
// load and
|
362
|
+
// present
|
363
|
+
// consent
|
364
|
+
// form.");
|
365
|
+
|
366
|
+
[UMPConsentForm loadAndPresentIfRequiredFromViewController:
|
367
|
+
self.viewController
|
368
|
+
completionHandler:
|
369
|
+
^(NSError
|
370
|
+
*loadAndPresentError) {
|
371
|
+
if (loadAndPresentError !=
|
372
|
+
nil) {
|
373
|
+
// NSLog(@"Error loading and presenting consent form: %@", loadAndPresentError);
|
374
|
+
CDVPluginResult
|
375
|
+
*pluginResult = [CDVPluginResult
|
376
|
+
resultWithStatus:
|
377
|
+
CDVCommandStatus_ERROR
|
378
|
+
messageAsString:
|
379
|
+
loadAndPresentError
|
380
|
+
.description];
|
381
|
+
[self.commandDelegate
|
382
|
+
sendPluginResult:
|
383
|
+
pluginResult
|
384
|
+
callbackId:
|
385
|
+
command
|
386
|
+
.callbackId];
|
387
|
+
} else {
|
388
|
+
// NSLog(@"Consent form successfully loaded");
|
389
|
+
[UMPConsentForm
|
390
|
+
presentPrivacyOptionsFormFromViewController:
|
391
|
+
self.viewController
|
392
|
+
completionHandler:^(
|
393
|
+
NSError
|
394
|
+
*_Nullable formError) {
|
395
|
+
if (formError) {
|
396
|
+
// NSLog(@"Error when displaying the form: %@", formError);
|
397
|
+
} else {
|
398
|
+
// NSLog(@"The privacy options form is successfully displayed.");
|
399
|
+
}
|
400
|
+
}];
|
401
|
+
}
|
402
|
+
}];
|
403
|
+
}];
|
404
|
+
});
|
312
405
|
}
|
313
406
|
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
407
|
- (void)showPrivacyOptionsForm:(CDVInvokedUrlCommand *)command {
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
408
|
+
NSString *deviceId = [self __getAdMobDeviceId];
|
409
|
+
UMPRequestParameters *parameters = [[UMPRequestParameters alloc] init];
|
410
|
+
|
411
|
+
if (isDebugGeography) {
|
412
|
+
UMPDebugSettings *debugSettings = [[UMPDebugSettings alloc] init];
|
413
|
+
parameters.debugSettings = debugSettings;
|
414
|
+
debugSettings.geography = UMPDebugGeographyEEA;
|
415
|
+
debugSettings.testDeviceIdentifiers = @[ deviceId ];
|
416
|
+
|
417
|
+
// NSLog(@"[showPrivacyOptionsForm] Using EEA debug geography for
|
418
|
+
// consent.");
|
419
|
+
}
|
420
|
+
|
421
|
+
parameters.tagForUnderAgeOfConsent = UnderAgeOfConsent;
|
422
|
+
|
423
|
+
dispatch_async(dispatch_get_main_queue(),
|
424
|
+
^{
|
425
|
+
[UMPConsentInformation.sharedInstance requestConsentInfoUpdateWithParameters:
|
426
|
+
parameters
|
427
|
+
completionHandler:^(
|
428
|
+
NSError
|
429
|
+
*_Nullable requestConsentError) {
|
430
|
+
if (requestConsentError !=
|
431
|
+
nil) {
|
432
|
+
// NSLog(@"[showPrivacyOptionsForm] Error in updating consent info: %@", requestConsentError);
|
433
|
+
CDVPluginResult
|
434
|
+
*pluginResult = [CDVPluginResult
|
435
|
+
resultWithStatus:
|
436
|
+
CDVCommandStatus_ERROR
|
437
|
+
messageAsString:
|
438
|
+
requestConsentError
|
439
|
+
.description];
|
440
|
+
[self.commandDelegate
|
441
|
+
sendPluginResult:
|
442
|
+
pluginResult
|
443
|
+
callbackId:
|
444
|
+
command
|
445
|
+
.callbackId];
|
446
|
+
return;
|
447
|
+
}
|
448
|
+
|
449
|
+
// NSLog(@"[showPrivacyOptionsForm] Successful update of consent info. Continue to load and present consent form.");
|
450
|
+
|
451
|
+
[UMPConsentForm
|
452
|
+
loadAndPresentIfRequiredFromViewController:
|
453
|
+
self.viewController
|
454
|
+
completionHandler:^(
|
455
|
+
NSError
|
456
|
+
*loadAndPresentError) {
|
457
|
+
if (loadAndPresentError) {
|
458
|
+
// NSLog(@"[showPrivacyOptionsForm] Error loading and presenting consent form: %@", loadAndPresentError);
|
459
|
+
CDVPluginResult
|
460
|
+
*pluginResult = [CDVPluginResult
|
461
|
+
resultWithStatus:
|
462
|
+
CDVCommandStatus_ERROR
|
463
|
+
messageAsString:
|
464
|
+
loadAndPresentError
|
465
|
+
.description];
|
466
|
+
[self.commandDelegate
|
467
|
+
sendPluginResult:
|
468
|
+
pluginResult
|
469
|
+
callbackId:
|
470
|
+
command
|
471
|
+
.callbackId];
|
472
|
+
} else {
|
473
|
+
/// NSLog(@"[showPrivacyOptionsForm] Consent form successfully displayed.");
|
474
|
+
}
|
475
|
+
}];
|
476
|
+
|
477
|
+
if ([self
|
478
|
+
isPrivacyOptionsRequired]) {
|
479
|
+
// NSLog(@"[isPrivacyOptionsRequired] Privacy options required.");
|
480
|
+
[self
|
481
|
+
privacyOptionsFormShow:
|
482
|
+
command];
|
483
|
+
} else {
|
484
|
+
// NSLog(@"[isPrivacyOptionsRequired] Privacy option form not required.");
|
485
|
+
CDVPluginResult
|
486
|
+
*pluginResult = [CDVPluginResult
|
487
|
+
resultWithStatus:
|
488
|
+
CDVCommandStatus_OK
|
489
|
+
messageAsString:
|
490
|
+
@"The privacy option form is not required."];
|
491
|
+
[self.commandDelegate
|
492
|
+
sendPluginResult:
|
493
|
+
pluginResult
|
494
|
+
callbackId:
|
495
|
+
command
|
496
|
+
.callbackId];
|
497
|
+
}
|
498
|
+
}];
|
499
|
+
});
|
368
500
|
}
|
369
501
|
|
370
|
-
|
371
502
|
- (void)privacyOptionsFormShow:(CDVInvokedUrlCommand *)command {
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
503
|
+
[self.commandDelegate runInBackground:^{
|
504
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
505
|
+
[UMPConsentForm
|
506
|
+
presentPrivacyOptionsFormFromViewController:self.viewController
|
507
|
+
completionHandler:^(
|
508
|
+
NSError *_Nullable formError) {
|
509
|
+
if (formError) {
|
510
|
+
// NSLog(@"[privacyOptionsFormShow]
|
511
|
+
// Error displaying the privacy options
|
512
|
+
// form: %@", formError);
|
513
|
+
CDVPluginResult *pluginResult =
|
514
|
+
[CDVPluginResult
|
515
|
+
resultWithStatus:
|
516
|
+
CDVCommandStatus_ERROR
|
517
|
+
messageAsString:
|
518
|
+
formError.description];
|
519
|
+
[self.commandDelegate
|
520
|
+
sendPluginResult:pluginResult
|
521
|
+
callbackId:command
|
522
|
+
.callbackId];
|
523
|
+
} else {
|
524
|
+
// NSLog(@"[privacyOptionsFormShow] The
|
525
|
+
// privacy options form is successfully
|
526
|
+
// displayed.");
|
527
|
+
}
|
528
|
+
}];
|
529
|
+
});
|
530
|
+
}];
|
386
531
|
}
|
387
532
|
|
388
533
|
// Cek apakah opsi privasi diperlukan
|
389
534
|
- (BOOL)isPrivacyOptionsRequired {
|
390
|
-
|
391
|
-
|
392
|
-
|
535
|
+
UMPPrivacyOptionsRequirementStatus status =
|
536
|
+
UMPConsentInformation.sharedInstance.privacyOptionsRequirementStatus;
|
537
|
+
// NSLog(@"[isPrivacyOptionsRequired] Privacy option status: %ld",
|
538
|
+
// (long)status);
|
539
|
+
return status == UMPPrivacyOptionsRequirementStatusRequired;
|
393
540
|
}
|
394
541
|
|
395
|
-
|
396
542
|
- (void)readStatus:(CDVInvokedUrlCommand *)command {
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
if (Consent_Status == UMPConsentStatusUnknown) {
|
401
|
-
|
402
|
-
Consent_Status = UMPConsentStatusUnknown;
|
403
|
-
} else if (Consent_Status == UMPConsentStatusRequired) {
|
404
|
-
|
405
|
-
Consent_Status = UMPConsentStatusRequired;
|
406
|
-
} else if (Consent_Status == UMPConsentStatusNotRequired) {
|
407
|
-
|
408
|
-
Consent_Status = UMPConsentStatusNotRequired;
|
409
|
-
} else if (Consent_Status == UMPConsentStatusObtained) {
|
410
|
-
|
411
|
-
Consent_Status = UMPConsentStatusObtained;
|
412
|
-
}
|
413
|
-
|
414
|
-
NSLog(@"The Consent " @"Status %i",
|
415
|
-
Consent_Status);
|
416
|
-
CDVPluginResult *pluginResult =
|
417
|
-
[CDVPluginResult resultWithStatus:CDVCommandStatus_OK
|
418
|
-
messageAsInt:Consent_Status];
|
419
|
-
[self.commandDelegate sendPluginResult:pluginResult
|
420
|
-
callbackId:command.callbackId];
|
421
|
-
}];
|
422
|
-
}
|
423
|
-
|
424
|
-
|
425
|
-
- (void)getIabTfc:(CDVInvokedUrlCommand *)command {
|
426
|
-
CDVPluginResult *pluginResult;
|
427
|
-
NSString *callbackId = command.callbackId;
|
428
|
-
if (isIAB == 1) {
|
429
|
-
NSMutableDictionary *result = [[NSMutableDictionary alloc] init];
|
430
|
-
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
|
431
|
-
NSNumber *CmpSdkID = [prefs valueForKey:@"IABT"
|
432
|
-
@"CF_"
|
433
|
-
@"CmpS"
|
434
|
-
@"dkI"
|
435
|
-
@"D"];
|
436
|
-
NSString *gdprApplies = [prefs stringForKey:@"IABT"
|
437
|
-
@"CF_"
|
438
|
-
@"gdpr"
|
439
|
-
@"Appl"
|
440
|
-
@"ie"
|
441
|
-
@"s"];
|
442
|
-
NSString *PurposeConsents = [prefs stringForKey:@"IABT"
|
443
|
-
@"CF_"
|
444
|
-
@"Purp"
|
445
|
-
@"oseC"
|
446
|
-
@"onse"
|
447
|
-
@"nt"
|
448
|
-
@"s"];
|
449
|
-
NSString *TCString = [prefs stringForKey:@"IABT"
|
450
|
-
@"CF_"
|
451
|
-
@"TCSt"
|
452
|
-
@"rin"
|
453
|
-
@"g"];
|
454
|
-
result[@"IABTCF_"
|
455
|
-
@"CmpSdkID"] = CmpSdkID;
|
456
|
-
result[@"IABTCF_"
|
457
|
-
@"gdprAppli"
|
458
|
-
@"es"] = gdprApplies;
|
459
|
-
result[@"IABTCF_"
|
460
|
-
@"PurposeCo"
|
461
|
-
@"nsents"] = PurposeConsents;
|
462
|
-
result[@"IABTCF_"
|
463
|
-
@"TCString"] = TCString;
|
464
|
-
[[NSUserDefaults standardUserDefaults] synchronize];
|
465
|
-
NSLog(@"%@",
|
466
|
-
[[NSUserDefaults standardUserDefaults] dictionaryRepresentation]);
|
467
|
-
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK
|
468
|
-
messageAsDictionary:result];
|
469
|
-
[self fireEvent:@""
|
470
|
-
event:@"on."
|
471
|
-
@"getI"
|
472
|
-
@"abTf"
|
473
|
-
@"c"
|
474
|
-
withData:nil];
|
475
|
-
} else {
|
476
|
-
pluginResult =
|
477
|
-
[CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
|
478
|
-
}
|
479
|
-
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
480
|
-
}
|
481
|
-
- (void)consentReset:(CDVInvokedUrlCommand *)command {
|
482
|
-
CDVPluginResult *pluginResult;
|
483
|
-
NSString *callbackId = command.callbackId;
|
484
|
-
@try {
|
485
|
-
[[UMPConsentInformation sharedInstance] reset];
|
486
|
-
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
487
|
-
} @catch (NSException *exception) {
|
488
|
-
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR
|
489
|
-
messageAsString:exception.reason];
|
490
|
-
}
|
491
|
-
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
492
|
-
}
|
543
|
+
[self.commandDelegate runInBackground:^{
|
544
|
+
Consent_Status = (int)UMPConsentInformation.sharedInstance.consentStatus;
|
493
545
|
|
546
|
+
if (Consent_Status == UMPConsentStatusUnknown) {
|
494
547
|
|
548
|
+
Consent_Status = UMPConsentStatusUnknown;
|
549
|
+
} else if (Consent_Status == UMPConsentStatusRequired) {
|
495
550
|
|
551
|
+
Consent_Status = UMPConsentStatusRequired;
|
552
|
+
} else if (Consent_Status == UMPConsentStatusNotRequired) {
|
496
553
|
|
554
|
+
Consent_Status = UMPConsentStatusNotRequired;
|
555
|
+
} else if (Consent_Status == UMPConsentStatusObtained) {
|
497
556
|
|
498
|
-
|
499
|
-
- (void)globalSettings:(CDVInvokedUrlCommand *)command {
|
500
|
-
CDVPluginResult *pluginResult;
|
501
|
-
NSString *callbackId = command.callbackId;
|
502
|
-
NSDictionary *options = [command.arguments objectAtIndex:0];
|
503
|
-
BOOL setAppMuted = [[options valueForKey:@"setAppMuted"] boolValue];
|
504
|
-
BOOL setAppVolume = [[options valueForKey:@"setAppVolume"] boolValue];
|
505
|
-
BOOL pubIdEnabled = [[options valueForKey:@"pubIdEnabled"] boolValue];
|
506
|
-
@try {
|
507
|
-
GADMobileAds.sharedInstance.applicationVolume = setAppVolume;
|
508
|
-
GADMobileAds.sharedInstance.applicationMuted = setAppMuted;
|
509
|
-
[GADMobileAds.sharedInstance.requestConfiguration setPublisherFirstPartyIDEnabled:pubIdEnabled];
|
510
|
-
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
511
|
-
} @catch (NSException *exception) {
|
512
|
-
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR
|
513
|
-
messageAsString:exception.reason];
|
557
|
+
Consent_Status = UMPConsentStatusObtained;
|
514
558
|
}
|
515
|
-
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
516
|
-
}
|
517
|
-
|
518
559
|
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
requestConfiguration.tagForChildDirectedTreatment = @(childDirectedTreatment);
|
529
|
-
requestConfiguration.tagForUnderAgeOfConsent = @(underAgeOfConsent);
|
530
|
-
|
531
|
-
if (contentRating != nil) {
|
532
|
-
if ([contentRating isEqualToString:@"G"]) {
|
533
|
-
requestConfiguration.maxAdContentRating = GADMaxAdContentRatingGeneral;
|
534
|
-
} else if ([contentRating isEqualToString:@"PG"]) {
|
535
|
-
requestConfiguration.maxAdContentRating = GADMaxAdContentRatingParentalGuidance;
|
536
|
-
} else if ([contentRating isEqualToString:@"T"]) {
|
537
|
-
requestConfiguration.maxAdContentRating = GADMaxAdContentRatingTeen;
|
538
|
-
} else if ([contentRating isEqualToString:@"MA"]) {
|
539
|
-
requestConfiguration.maxAdContentRating = GADMaxAdContentRatingMatureAudience;
|
540
|
-
} else {
|
541
|
-
// NSLog(@"Unknown content rating: %@", contentRating);
|
542
|
-
}
|
543
|
-
}
|
544
|
-
|
545
|
-
UnderAgeOfConsent = underAgeOfConsent;
|
546
|
-
|
547
|
-
} @catch (NSException *exception) {
|
548
|
-
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR
|
549
|
-
messageAsString:exception.reason];
|
550
|
-
}
|
551
|
-
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
560
|
+
/* NSLog(@"The Consent "
|
561
|
+
@"Status %i",
|
562
|
+
Consent_Status); */
|
563
|
+
CDVPluginResult *pluginResult =
|
564
|
+
[CDVPluginResult resultWithStatus:CDVCommandStatus_OK
|
565
|
+
messageAsInt:Consent_Status];
|
566
|
+
[self.commandDelegate sendPluginResult:pluginResult
|
567
|
+
callbackId:command.callbackId];
|
568
|
+
}];
|
552
569
|
}
|
553
570
|
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
[super pluginInitialize];
|
559
|
-
|
560
|
-
[[NSNotificationCenter defaultCenter] addObserver:self
|
561
|
-
selector:@selector(orientationDidChange:)
|
562
|
-
name:UIDeviceOrientationDidChangeNotification
|
563
|
-
object:nil];
|
564
|
-
|
565
|
-
isIAB = YES;
|
571
|
+
- (void)getIabTfc:(CDVInvokedUrlCommand *)command {
|
572
|
+
CDVPluginResult *pluginResult;
|
573
|
+
NSString *callbackId = command.callbackId;
|
574
|
+
if (isIAB == 1) {
|
566
575
|
NSMutableDictionary *result = [[NSMutableDictionary alloc] init];
|
567
576
|
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
|
568
|
-
NSNumber *CmpSdkID = [prefs valueForKey:@"
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
NSString *
|
580
|
-
|
581
|
-
|
577
|
+
NSNumber *CmpSdkID = [prefs valueForKey:@"IABT"
|
578
|
+
@"CF_"
|
579
|
+
@"CmpS"
|
580
|
+
@"dkI"
|
581
|
+
@"D"];
|
582
|
+
NSString *gdprApplies = [prefs stringForKey:@"IABT"
|
583
|
+
@"CF_"
|
584
|
+
@"gdpr"
|
585
|
+
@"Appl"
|
586
|
+
@"ie"
|
587
|
+
@"s"];
|
588
|
+
NSString *PurposeConsents = [prefs stringForKey:@"IABT"
|
589
|
+
@"CF_"
|
590
|
+
@"Purp"
|
591
|
+
@"oseC"
|
592
|
+
@"onse"
|
593
|
+
@"nt"
|
594
|
+
@"s"];
|
595
|
+
NSString *TCString = [prefs stringForKey:@"IABT"
|
596
|
+
@"CF_"
|
597
|
+
@"TCSt"
|
598
|
+
@"rin"
|
599
|
+
@"g"];
|
582
600
|
result[@"IABTCF_"
|
583
601
|
@"CmpSdkID"] = CmpSdkID;
|
584
602
|
result[@"IABTCF_"
|
585
|
-
@"
|
603
|
+
@"gdprAppli"
|
604
|
+
@"es"] = gdprApplies;
|
586
605
|
result[@"IABTCF_"
|
587
|
-
@"
|
588
|
-
@"
|
606
|
+
@"PurposeCo"
|
607
|
+
@"nsents"] = PurposeConsents;
|
589
608
|
result[@"IABTCF_"
|
590
609
|
@"TCString"] = TCString;
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
[
|
596
|
-
|
597
|
-
|
598
|
-
|
610
|
+
[[NSUserDefaults standardUserDefaults] synchronize];
|
611
|
+
NSLog(@"%@", [[NSUserDefaults standardUserDefaults] dictionaryRepresentation]);
|
612
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK
|
613
|
+
messageAsDictionary:result];
|
614
|
+
[self fireEvent:@""
|
615
|
+
event:@"on."
|
616
|
+
@"getI"
|
617
|
+
@"abTf"
|
618
|
+
@"c"
|
619
|
+
withData:nil];
|
620
|
+
} else {
|
621
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
|
622
|
+
}
|
623
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
624
|
+
}
|
625
|
+
- (void)consentReset:(CDVInvokedUrlCommand *)command {
|
626
|
+
CDVPluginResult *pluginResult;
|
627
|
+
NSString *callbackId = command.callbackId;
|
628
|
+
@try {
|
629
|
+
[[UMPConsentInformation sharedInstance] reset];
|
630
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
631
|
+
} @catch (NSException *exception) {
|
632
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR
|
633
|
+
messageAsString:exception.reason];
|
634
|
+
}
|
635
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
599
636
|
}
|
600
637
|
|
638
|
+
- (void)globalSettings:(CDVInvokedUrlCommand *)command {
|
639
|
+
CDVPluginResult *pluginResult;
|
640
|
+
NSString *callbackId = command.callbackId;
|
641
|
+
NSDictionary *options = [command.arguments objectAtIndex:0];
|
642
|
+
BOOL setAppMuted = [[options valueForKey:@"setAppMuted"] boolValue];
|
643
|
+
BOOL setAppVolume = [[options valueForKey:@"setAppVolume"] boolValue];
|
644
|
+
BOOL pubIdEnabled = [[options valueForKey:@"pubIdEnabled"] boolValue];
|
645
|
+
@try {
|
646
|
+
GADMobileAds.sharedInstance.applicationVolume = setAppVolume;
|
647
|
+
GADMobileAds.sharedInstance.applicationMuted = setAppMuted;
|
648
|
+
[GADMobileAds.sharedInstance.requestConfiguration
|
649
|
+
setPublisherFirstPartyIDEnabled:pubIdEnabled];
|
650
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
651
|
+
} @catch (NSException *exception) {
|
652
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR
|
653
|
+
messageAsString:exception.reason];
|
654
|
+
}
|
655
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
656
|
+
}
|
601
657
|
|
658
|
+
- (void)targeting:(CDVInvokedUrlCommand *)command {
|
659
|
+
CDVPluginResult *pluginResult;
|
660
|
+
NSString *callbackId = command.callbackId;
|
661
|
+
NSDictionary *options = [command.arguments objectAtIndex:0];
|
662
|
+
BOOL childDirectedTreatment =
|
663
|
+
[[options valueForKey:@"childDirectedTreatment"] boolValue];
|
664
|
+
BOOL underAgeOfConsent =
|
665
|
+
[[options valueForKey:@"underAgeOfConsent"] boolValue];
|
666
|
+
NSString *contentRating = [options valueForKey:@"contentRating"];
|
667
|
+
@try {
|
668
|
+
GADRequestConfiguration *requestConfiguration =
|
669
|
+
GADMobileAds.sharedInstance.requestConfiguration;
|
670
|
+
requestConfiguration.tagForChildDirectedTreatment =
|
671
|
+
@(childDirectedTreatment);
|
672
|
+
requestConfiguration.tagForUnderAgeOfConsent = @(underAgeOfConsent);
|
673
|
+
|
674
|
+
if (contentRating != nil) {
|
675
|
+
if ([contentRating isEqualToString:@"G"]) {
|
676
|
+
requestConfiguration.maxAdContentRating = GADMaxAdContentRatingGeneral;
|
677
|
+
} else if ([contentRating isEqualToString:@"PG"]) {
|
678
|
+
requestConfiguration.maxAdContentRating =
|
679
|
+
GADMaxAdContentRatingParentalGuidance;
|
680
|
+
} else if ([contentRating isEqualToString:@"T"]) {
|
681
|
+
requestConfiguration.maxAdContentRating = GADMaxAdContentRatingTeen;
|
682
|
+
} else if ([contentRating isEqualToString:@"MA"]) {
|
683
|
+
requestConfiguration.maxAdContentRating =
|
684
|
+
GADMaxAdContentRatingMatureAudience;
|
685
|
+
} else {
|
686
|
+
// NSLog(@"Unknown content rating: %@", contentRating);
|
687
|
+
}
|
688
|
+
}
|
602
689
|
|
690
|
+
UnderAgeOfConsent = underAgeOfConsent;
|
603
691
|
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
if (isAutoResize) {
|
610
|
-
dispatch_async(dispatch_get_main_queue(), ^{
|
611
|
-
@try {
|
612
|
-
|
613
|
-
if (self.bannerView) {
|
614
|
-
UIView *parentView = self.bannerView.superview;
|
615
|
-
if (parentView != nil) {
|
616
|
-
[self.bannerView removeFromSuperview];
|
617
|
-
}
|
618
|
-
}
|
619
|
-
|
620
|
-
self.bannerViewLayout = [[UIView alloc] initWithFrame:CGRectZero];
|
621
|
-
self.bannerViewLayout.translatesAutoresizingMaskIntoConstraints = NO;
|
622
|
-
|
623
|
-
UIView *rootView = self.viewController.view;
|
624
|
-
if ([rootView isKindOfClass:[UIView class]]) {
|
625
|
-
[rootView addSubview:self.bannerViewLayout];
|
626
|
-
|
627
|
-
|
628
|
-
[self.bannerViewLayout.topAnchor constraintEqualToAnchor:rootView.topAnchor].active = YES;
|
629
|
-
[self.bannerViewLayout.leadingAnchor constraintEqualToAnchor:rootView.leadingAnchor].active = YES;
|
630
|
-
[self.bannerViewLayout.trailingAnchor constraintEqualToAnchor:rootView.trailingAnchor].active = YES;
|
631
|
-
[self.bannerViewLayout.heightAnchor constraintEqualToConstant:50].active = YES;
|
632
|
-
}
|
633
|
-
|
634
|
-
|
635
|
-
self.bannerView = [[GADBannerView alloc] initWithAdSize:GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth(rootView.frame.size.width)];
|
636
|
-
self.bannerView.adUnitID = bannerSaveAdUnitId;
|
637
|
-
self.bannerView.delegate = self;
|
638
|
-
[self.bannerView loadRequest:[GADRequest request]];
|
639
|
-
|
640
|
-
|
641
|
-
[self.bannerViewLayout addSubview:self.bannerView];
|
642
|
-
[self.bannerViewLayout bringSubviewToFront:self.bannerView];
|
643
|
-
|
644
|
-
} @catch (NSException *exception) {
|
645
|
-
// NSLog(@"Error adjusting banner size: %@", exception.reason);
|
646
|
-
// PUBLIC_CALLBACKS.error([NSString stringWithFormat:@"Error adjusting banner size: %@", exception.reason]);
|
647
|
-
}
|
648
|
-
});
|
649
|
-
}
|
692
|
+
} @catch (NSException *exception) {
|
693
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR
|
694
|
+
messageAsString:exception.reason];
|
695
|
+
}
|
696
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
650
697
|
}
|
651
698
|
|
699
|
+
- (void)pluginInitialize {
|
700
|
+
[super pluginInitialize];
|
701
|
+
|
702
|
+
[[NSNotificationCenter defaultCenter]
|
703
|
+
addObserver:self
|
704
|
+
selector:@selector(orientationDidChange:)
|
705
|
+
name:UIDeviceOrientationDidChangeNotification
|
706
|
+
object:nil];
|
707
|
+
|
708
|
+
isIAB = YES;
|
709
|
+
NSMutableDictionary *result = [[NSMutableDictionary alloc] init];
|
710
|
+
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
|
711
|
+
NSNumber *CmpSdkID = [prefs valueForKey:@"IABTCF"
|
712
|
+
@"_CmpSd"
|
713
|
+
@"kID"];
|
714
|
+
NSString *gdprApplies = [prefs stringForKey:@"IABTCF"
|
715
|
+
@"_gdprA"
|
716
|
+
@"pplie"
|
717
|
+
@"s"];
|
718
|
+
NSString *PurposeConsents = [prefs stringForKey:@"IABTCF"
|
719
|
+
@"_Purpo"
|
720
|
+
@"seCons"
|
721
|
+
@"ents"];
|
722
|
+
NSString *TCString = [prefs stringForKey:@"IABTCF"
|
723
|
+
@"_TCStr"
|
724
|
+
@"ing"];
|
725
|
+
result[@"IABTCF_"
|
726
|
+
@"CmpSdkID"] = CmpSdkID;
|
727
|
+
result[@"IABTCF_"
|
728
|
+
@"gdprApplies"] = gdprApplies;
|
729
|
+
result[@"IABTCF_"
|
730
|
+
@"PurposeCons"
|
731
|
+
@"ents"] = PurposeConsents;
|
732
|
+
result[@"IABTCF_"
|
733
|
+
@"TCString"] = TCString;
|
734
|
+
// NSLog(@"%@",
|
735
|
+
// [[NSUserDefaults
|
736
|
+
// standardUserDefaults]
|
737
|
+
// dictionaryRepresentation]);
|
738
|
+
[prefs synchronize];
|
739
|
+
}
|
652
740
|
|
741
|
+
- (void)orientationDidChange:(NSNotification *)notification {
|
742
|
+
// NSLog(@"Orientation changed");
|
743
|
+
[self fireEvent:@"" event:@"on.screen.rotated" withData:nil];
|
744
|
+
if (isAutoResize) {
|
745
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
746
|
+
@try {
|
653
747
|
|
748
|
+
if (self.bannerView) {
|
749
|
+
UIView *parentView = self.bannerView.superview;
|
750
|
+
if (parentView != nil) {
|
751
|
+
[self.bannerView removeFromSuperview];
|
752
|
+
}
|
753
|
+
}
|
654
754
|
|
755
|
+
self.bannerViewLayout = [[UIView alloc] initWithFrame:CGRectZero];
|
756
|
+
self.bannerViewLayout.translatesAutoresizingMaskIntoConstraints = NO;
|
757
|
+
|
758
|
+
UIView *rootView = self.viewController.view;
|
759
|
+
if ([rootView isKindOfClass:[UIView class]]) {
|
760
|
+
[rootView addSubview:self.bannerViewLayout];
|
761
|
+
|
762
|
+
[self.bannerViewLayout.topAnchor
|
763
|
+
constraintEqualToAnchor:rootView.topAnchor]
|
764
|
+
.active = YES;
|
765
|
+
[self.bannerViewLayout.leadingAnchor
|
766
|
+
constraintEqualToAnchor:rootView.leadingAnchor]
|
767
|
+
.active = YES;
|
768
|
+
[self.bannerViewLayout.trailingAnchor
|
769
|
+
constraintEqualToAnchor:rootView.trailingAnchor]
|
770
|
+
.active = YES;
|
771
|
+
[self.bannerViewLayout.heightAnchor constraintEqualToConstant:50]
|
772
|
+
.active = YES;
|
773
|
+
}
|
655
774
|
|
775
|
+
self.bannerView = [[GADBannerView alloc]
|
776
|
+
initWithAdSize:
|
777
|
+
GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth(
|
778
|
+
rootView.frame.size.width)];
|
779
|
+
self.bannerView.adUnitID = bannerSaveAdUnitId;
|
780
|
+
self.bannerView.delegate = self;
|
781
|
+
[self.bannerView loadRequest:[GADRequest request]];
|
782
|
+
|
783
|
+
[self.bannerViewLayout addSubview:self.bannerView];
|
784
|
+
[self.bannerViewLayout bringSubviewToFront:self.bannerView];
|
785
|
+
|
786
|
+
} @catch (NSException *exception) {
|
787
|
+
// NSLog(@"Error adjusting banner size: %@", exception.reason);
|
788
|
+
// PUBLIC_CALLBACKS.error([NSString stringWithFormat:@"Error adjusting
|
789
|
+
// banner size: %@", exception.reason]);
|
790
|
+
}
|
791
|
+
});
|
792
|
+
}
|
793
|
+
}
|
656
794
|
|
657
795
|
- (void)addBannerConstraints {
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
796
|
+
self.bannerView.translatesAutoresizingMaskIntoConstraints = NO;
|
797
|
+
|
798
|
+
// Tambahkan constraint berdasarkan posisi
|
799
|
+
if ([Position isEqualToString:@"bottom-center"]) {
|
800
|
+
[self.viewController.view addConstraints:@[
|
801
|
+
[NSLayoutConstraint
|
802
|
+
constraintWithItem:self.bannerView
|
803
|
+
attribute:NSLayoutAttributeBottom
|
804
|
+
relatedBy:NSLayoutRelationEqual
|
805
|
+
toItem:self.viewController.view.safeAreaLayoutGuide
|
806
|
+
attribute:NSLayoutAttributeBottom
|
807
|
+
multiplier:1
|
808
|
+
constant:0],
|
809
|
+
[NSLayoutConstraint constraintWithItem:self.bannerView
|
810
|
+
attribute:NSLayoutAttributeCenterX
|
811
|
+
relatedBy:NSLayoutRelationEqual
|
812
|
+
toItem:self.viewController.view
|
813
|
+
attribute:NSLayoutAttributeCenterX
|
814
|
+
multiplier:1
|
815
|
+
constant:0]
|
816
|
+
]];
|
817
|
+
} else if ([Position isEqualToString:@"top-center"]) {
|
818
|
+
[self.viewController.view addConstraints:@[
|
819
|
+
[NSLayoutConstraint
|
820
|
+
constraintWithItem:self.bannerView
|
821
|
+
attribute:NSLayoutAttributeTop
|
822
|
+
relatedBy:NSLayoutRelationEqual
|
823
|
+
toItem:self.viewController.view.safeAreaLayoutGuide
|
824
|
+
attribute:NSLayoutAttributeTop
|
825
|
+
multiplier:1
|
826
|
+
constant:0],
|
827
|
+
[NSLayoutConstraint constraintWithItem:self.bannerView
|
828
|
+
attribute:NSLayoutAttributeCenterX
|
829
|
+
relatedBy:NSLayoutRelationEqual
|
830
|
+
toItem:self.viewController.view
|
831
|
+
attribute:NSLayoutAttributeCenterX
|
832
|
+
multiplier:1
|
833
|
+
constant:0]
|
834
|
+
]];
|
835
|
+
}
|
696
836
|
}
|
697
837
|
|
838
|
+
- (void)loadBannerAd:(CDVInvokedUrlCommand *)command {
|
839
|
+
CDVPluginResult *pluginResult;
|
840
|
+
NSString *callbackId = command.callbackId;
|
841
|
+
adFormat = 3;
|
842
|
+
NSDictionary *options = [command.arguments objectAtIndex:0];
|
843
|
+
NSString *adUnitId = [options valueForKey:@"adUnitId"];
|
844
|
+
NSString *position = [options valueForKey:@"position"];
|
845
|
+
NSString *collapsible = [options valueForKey:@"collapsible"];
|
846
|
+
BOOL autoResize = [[options valueForKey:@"autoResize"] boolValue];
|
847
|
+
NSString *size = [options valueForKey:@"size"];
|
848
|
+
BOOL autoShow = [[options valueForKey:@"autoShow"] boolValue];
|
849
|
+
|
850
|
+
bannerSaveAdUnitId = adUnitId;
|
851
|
+
|
852
|
+
if (adUnitId == nil || [adUnitId length] == 0) {
|
853
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR
|
854
|
+
messageAsString:@"Ad unit ID is required"];
|
855
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
856
|
+
return;
|
857
|
+
}
|
698
858
|
|
859
|
+
if (collapsible != nil && [collapsible length] > 0) {
|
860
|
+
enableCollapsible = YES;
|
861
|
+
} else {
|
862
|
+
enableCollapsible = NO;
|
863
|
+
}
|
699
864
|
|
865
|
+
if (autoResize) {
|
700
866
|
|
867
|
+
isAutoResize = YES;
|
868
|
+
}
|
701
869
|
|
870
|
+
if (adFormat == 3) {
|
871
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
872
|
+
UIView *parentView = [self.webView superview];
|
873
|
+
CGRect frame = self.bannerView.frame;
|
702
874
|
|
875
|
+
if (@available(iOS 11.0, *)) {
|
876
|
+
UIEdgeInsets safeAreaInsets = self.bannerView.safeAreaInsets;
|
877
|
+
frame = UIEdgeInsetsInsetRect(frame, safeAreaInsets);
|
878
|
+
}
|
703
879
|
|
880
|
+
self.viewWidth = frame.size.width;
|
704
881
|
|
705
|
-
|
706
|
-
|
707
|
-
NSString *callbackId = command.callbackId;
|
708
|
-
adFormat = 3;
|
709
|
-
NSDictionary *options = [command.arguments objectAtIndex:0];
|
710
|
-
NSString *adUnitId = [options valueForKey:@"adUnitId"];
|
711
|
-
NSString *position = [options valueForKey:@"position"];
|
712
|
-
NSString *collapsible = [options valueForKey:@"collapsible"];
|
713
|
-
BOOL autoResize = [[options valueForKey:@"autoResize"] boolValue];
|
714
|
-
NSString *size = [options valueForKey:@"size"];
|
715
|
-
BOOL autoShow = [[options valueForKey:@"autoShow"] boolValue];
|
716
|
-
|
717
|
-
bannerSaveAdUnitId = adUnitId;
|
718
|
-
|
719
|
-
if (adUnitId == nil || [adUnitId length] == 0) {
|
720
|
-
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Ad unit ID is required"];
|
721
|
-
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
722
|
-
return;
|
723
|
-
}
|
724
|
-
|
725
|
-
if (collapsible != nil && [collapsible length] > 0) {
|
726
|
-
enableCollapsible = YES;
|
727
|
-
} else {
|
728
|
-
enableCollapsible = NO;
|
729
|
-
}
|
730
|
-
|
731
|
-
if (autoResize) {
|
732
|
-
|
733
|
-
isAutoResize = YES;
|
734
|
-
}
|
735
|
-
|
736
|
-
if (adFormat == 3) {
|
737
|
-
dispatch_async(dispatch_get_main_queue(), ^{
|
738
|
-
|
739
|
-
UIView *parentView = [self.webView superview];
|
740
|
-
CGRect frame = self.bannerView.frame;
|
741
|
-
|
742
|
-
if (@available(iOS 11.0, *)) {
|
743
|
-
UIEdgeInsets safeAreaInsets = self.bannerView.safeAreaInsets;
|
744
|
-
frame = UIEdgeInsetsInsetRect(frame, safeAreaInsets);
|
745
|
-
}
|
746
|
-
|
747
|
-
self.viewWidth = frame.size.width;
|
748
|
-
|
749
|
-
auto_Show = autoShow;
|
750
|
-
adWidth = self.viewWidth;
|
751
|
-
|
752
|
-
Position = position;
|
753
|
-
|
754
|
-
GADAdSize sizes = [self __AdSizeFromString:size];
|
755
|
-
self.bannerView = [[GADBannerView alloc] initWithAdSize:sizes];
|
756
|
-
|
757
|
-
GADRequest *request = [GADRequest request];
|
758
|
-
GADExtras *extras = [[GADExtras alloc] init];
|
759
|
-
|
760
|
-
if (enableCollapsible) {
|
761
|
-
extras.additionalParameters = @{@"collapsible" : collapsible};
|
762
|
-
}
|
763
|
-
|
764
|
-
[request registerAdNetworkExtras:extras];
|
765
|
-
|
766
|
-
self.bannerView.adUnitID = adUnitId;
|
767
|
-
self.bannerView.rootViewController = self.viewController;
|
768
|
-
self.bannerView.delegate = self;
|
769
|
-
[self.bannerView loadRequest:request];
|
770
|
-
self.bannerView.hidden = YES;
|
771
|
-
[parentView addSubview:self.bannerView];
|
772
|
-
[parentView bringSubviewToFront:self.bannerView];
|
773
|
-
});
|
774
|
-
|
775
|
-
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
776
|
-
} else {
|
777
|
-
// NSLog(@"Admob Option invalid for banner");
|
778
|
-
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
|
779
|
-
}
|
780
|
-
|
781
|
-
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
782
|
-
}
|
882
|
+
auto_Show = autoShow;
|
883
|
+
adWidth = self.viewWidth;
|
783
884
|
|
885
|
+
Position = position;
|
784
886
|
|
785
|
-
|
786
|
-
|
787
|
-
if (self.viewWidth == 0) {
|
788
|
-
self.viewWidth = [UIScreen mainScreen].bounds.size.width;
|
789
|
-
}
|
790
|
-
|
791
|
-
if ([size isEqualToString:@"responsive_adaptive"]) {
|
792
|
-
return GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth(self.viewWidth);
|
793
|
-
} else if ([size isEqualToString:@"in_line_adaptive"]) {
|
794
|
-
return GADCurrentOrientationInlineAdaptiveBannerAdSizeWithWidth(self.viewWidth);
|
795
|
-
} else if ([size isEqualToString:@"banner"]) {
|
796
|
-
return GADAdSizeBanner;
|
797
|
-
} else if ([size isEqualToString:@"large_banner"]) {
|
798
|
-
return GADAdSizeLargeBanner;
|
799
|
-
} else if ([size isEqualToString:@"full_banner"]) {
|
800
|
-
return GADAdSizeFullBanner;
|
801
|
-
} else if ([size isEqualToString:@"leaderboard"]) {
|
802
|
-
return GADAdSizeLeaderboard;
|
803
|
-
} else {
|
804
|
-
return GADAdSizeBanner;
|
805
|
-
}
|
806
|
-
}
|
887
|
+
GADAdSize sizes = [self __AdSizeFromString:size];
|
888
|
+
self.bannerView = [[GADBannerView alloc] initWithAdSize:sizes];
|
807
889
|
|
890
|
+
GADRequest *request = [GADRequest request];
|
891
|
+
GADExtras *extras = [[GADExtras alloc] init];
|
808
892
|
|
893
|
+
if (enableCollapsible) {
|
894
|
+
extras.additionalParameters = @{@"collapsible" : collapsible};
|
895
|
+
}
|
809
896
|
|
897
|
+
[request registerAdNetworkExtras:extras];
|
810
898
|
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
}
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
|
823
|
-
|
824
|
-
|
825
|
-
|
826
|
-
|
827
|
-
pluginResult =
|
828
|
-
[CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
|
829
|
-
}
|
830
|
-
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
899
|
+
self.bannerView.adUnitID = adUnitId;
|
900
|
+
self.bannerView.rootViewController = self.viewController;
|
901
|
+
self.bannerView.delegate = self;
|
902
|
+
[self.bannerView loadRequest:request];
|
903
|
+
self.bannerView.hidden = YES;
|
904
|
+
[parentView addSubview:self.bannerView];
|
905
|
+
[parentView bringSubviewToFront:self.bannerView];
|
906
|
+
});
|
907
|
+
|
908
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
909
|
+
} else {
|
910
|
+
// NSLog(@"Admob Option invalid for banner");
|
911
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
|
912
|
+
}
|
913
|
+
|
914
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
831
915
|
}
|
832
916
|
|
917
|
+
- (GADAdSize)__AdSizeFromString:(NSString *)size {
|
833
918
|
|
919
|
+
if (self.viewWidth == 0) {
|
920
|
+
self.viewWidth = [UIScreen mainScreen].bounds.size.width;
|
921
|
+
}
|
922
|
+
|
923
|
+
if ([size isEqualToString:@"responsive_adaptive"]) {
|
924
|
+
return GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth(
|
925
|
+
self.viewWidth);
|
926
|
+
} else if ([size isEqualToString:@"in_line_adaptive"]) {
|
927
|
+
return GADCurrentOrientationInlineAdaptiveBannerAdSizeWithWidth(
|
928
|
+
self.viewWidth);
|
929
|
+
} else if ([size isEqualToString:@"banner"]) {
|
930
|
+
return GADAdSizeBanner;
|
931
|
+
} else if ([size isEqualToString:@"large_banner"]) {
|
932
|
+
return GADAdSizeLargeBanner;
|
933
|
+
} else if ([size isEqualToString:@"full_banner"]) {
|
934
|
+
return GADAdSizeFullBanner;
|
935
|
+
} else if ([size isEqualToString:@"leaderboard"]) {
|
936
|
+
return GADAdSizeLeaderboard;
|
937
|
+
} else {
|
938
|
+
return GADAdSizeBanner;
|
939
|
+
}
|
940
|
+
}
|
834
941
|
|
942
|
+
- (void)showBannerAd:(CDVInvokedUrlCommand *)command {
|
943
|
+
CDVPluginResult *pluginResult;
|
944
|
+
NSString *callbackId = command.callbackId;
|
945
|
+
if (self.bannerView) {
|
946
|
+
self.bannerView.hidden = NO;
|
947
|
+
[self addBannerViewToView:command];
|
948
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
949
|
+
} else {
|
950
|
+
[self fireEvent:@""
|
951
|
+
event:@"on."
|
952
|
+
@"bann"
|
953
|
+
@"er."
|
954
|
+
@"fail"
|
955
|
+
@"ed."
|
956
|
+
@"show"
|
957
|
+
withData:nil];
|
958
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
|
959
|
+
}
|
960
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
961
|
+
}
|
835
962
|
|
836
963
|
- (void)addBannerViewToView:(CDVInvokedUrlCommand *)command {
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
|
857
|
-
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
|
867
|
-
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
882
|
-
|
883
|
-
|
884
|
-
|
885
|
-
|
886
|
-
|
887
|
-
|
888
|
-
|
889
|
-
|
890
|
-
|
891
|
-
|
892
|
-
|
893
|
-
|
894
|
-
|
895
|
-
|
896
|
-
}
|
964
|
+
bannerView.translatesAutoresizingMaskIntoConstraints = NO;
|
965
|
+
[self.viewController.view addSubview:bannerView];
|
966
|
+
if ([Position isEqualToString:@"bottom-center"]) {
|
967
|
+
[self.viewController.view addConstraints:@[
|
968
|
+
[NSLayoutConstraint
|
969
|
+
constraintWithItem:bannerView
|
970
|
+
attribute:NSLayoutAttributeBottom
|
971
|
+
relatedBy:NSLayoutRelationEqual
|
972
|
+
toItem:self.viewController.view.safeAreaLayoutGuide
|
973
|
+
attribute:NSLayoutAttributeBottom
|
974
|
+
multiplier:1
|
975
|
+
constant:0],
|
976
|
+
[NSLayoutConstraint constraintWithItem:bannerView
|
977
|
+
attribute:NSLayoutAttributeCenterX
|
978
|
+
relatedBy:NSLayoutRelationEqual
|
979
|
+
toItem:self.viewController.view
|
980
|
+
attribute:NSLayoutAttributeCenterX
|
981
|
+
multiplier:1
|
982
|
+
constant:0]
|
983
|
+
]];
|
984
|
+
} else if ([Position isEqualToString:@"top-center"]) {
|
985
|
+
|
986
|
+
[self.viewController.view addConstraints:@[
|
987
|
+
[NSLayoutConstraint
|
988
|
+
constraintWithItem:bannerView
|
989
|
+
attribute:NSLayoutAttributeTop
|
990
|
+
relatedBy:NSLayoutRelationEqual
|
991
|
+
toItem:self.viewController.view.safeAreaLayoutGuide
|
992
|
+
attribute:NSLayoutAttributeTop
|
993
|
+
multiplier:1
|
994
|
+
constant:0],
|
995
|
+
[NSLayoutConstraint constraintWithItem:bannerView
|
996
|
+
attribute:NSLayoutAttributeCenterX
|
997
|
+
relatedBy:NSLayoutRelationEqual
|
998
|
+
toItem:self.viewController.view
|
999
|
+
attribute:NSLayoutAttributeCenterX
|
1000
|
+
multiplier:1
|
1001
|
+
constant:0]
|
1002
|
+
]];
|
1003
|
+
|
1004
|
+
} else {
|
1005
|
+
[self.viewController.view addConstraints:@[
|
1006
|
+
[NSLayoutConstraint
|
1007
|
+
constraintWithItem:bannerView
|
1008
|
+
attribute:NSLayoutAttributeBottom
|
1009
|
+
relatedBy:NSLayoutRelationEqual
|
1010
|
+
toItem:self.viewController.view.safeAreaLayoutGuide
|
1011
|
+
attribute:NSLayoutAttributeTop
|
1012
|
+
multiplier:1
|
1013
|
+
constant:0],
|
1014
|
+
[NSLayoutConstraint constraintWithItem:bannerView
|
1015
|
+
attribute:NSLayoutAttributeCenterX
|
1016
|
+
relatedBy:NSLayoutRelationEqual
|
1017
|
+
toItem:self.viewController.view
|
1018
|
+
attribute:NSLayoutAttributeCenterX
|
1019
|
+
multiplier:1
|
1020
|
+
constant:0]
|
1021
|
+
]];
|
1022
|
+
}
|
897
1023
|
}
|
898
1024
|
- (void)hideBannerAd:(CDVInvokedUrlCommand *)command {
|
899
|
-
|
900
|
-
|
901
|
-
|
902
|
-
|
903
|
-
|
904
|
-
|
905
|
-
|
906
|
-
|
907
|
-
|
908
|
-
|
909
|
-
|
910
|
-
|
911
|
-
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
1025
|
+
CDVPluginResult *pluginResult;
|
1026
|
+
NSString *callbackId = command.callbackId;
|
1027
|
+
if (self.bannerView) {
|
1028
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
1029
|
+
self.bannerView.hidden = YES;
|
1030
|
+
[self fireEvent:@"" event:@"on.banner.hide" withData:nil];
|
1031
|
+
});
|
1032
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
1033
|
+
} else {
|
1034
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
|
1035
|
+
}
|
1036
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
912
1037
|
}
|
913
1038
|
- (void)removeBannerAd:(CDVInvokedUrlCommand *)command {
|
914
|
-
|
915
|
-
|
916
|
-
|
917
|
-
|
918
|
-
|
919
|
-
|
920
|
-
|
921
|
-
|
922
|
-
|
923
|
-
|
924
|
-
|
925
|
-
|
926
|
-
|
927
|
-
|
928
|
-
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
1039
|
+
CDVPluginResult *pluginResult;
|
1040
|
+
NSString *callbackId = command.callbackId;
|
1041
|
+
if (self.bannerView) {
|
1042
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
1043
|
+
self.bannerView.hidden = YES;
|
1044
|
+
[self.bannerView removeFromSuperview];
|
1045
|
+
self.bannerView = nil;
|
1046
|
+
[self fireEvent:@"" event:@"on.banner.remove" withData:nil];
|
1047
|
+
});
|
1048
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
1049
|
+
} else {
|
1050
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
|
1051
|
+
}
|
1052
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
929
1053
|
}
|
930
1054
|
- (void)loadAppOpenAd:(CDVInvokedUrlCommand *)command {
|
931
|
-
|
932
|
-
|
933
|
-
|
934
|
-
|
935
|
-
|
936
|
-
|
937
|
-
|
938
|
-
|
939
|
-
|
940
|
-
|
941
|
-
|
942
|
-
|
943
|
-
|
944
|
-
|
945
|
-
|
946
|
-
|
947
|
-
|
948
|
-
|
949
|
-
|
950
|
-
|
951
|
-
|
952
|
-
|
953
|
-
|
954
|
-
|
955
|
-
|
956
|
-
|
957
|
-
|
958
|
-
|
959
|
-
|
960
|
-
|
961
|
-
|
962
|
-
|
963
|
-
|
964
|
-
|
965
|
-
|
966
|
-
|
967
|
-
|
968
|
-
|
969
|
-
|
970
|
-
|
971
|
-
|
972
|
-
|
973
|
-
|
974
|
-
|
975
|
-
|
976
|
-
|
977
|
-
return;
|
978
|
-
}
|
979
|
-
self.appOpenAd = ad;
|
980
|
-
self.appOpenAd.fullScreenContentDelegate = self;
|
981
|
-
[self fireEvent:@"" event:@"on.appOpenAd.loaded" withData:nil];
|
982
|
-
if (auto_Show) {
|
983
|
-
if (self.appOpenAd &&
|
984
|
-
[self.appOpenAd
|
985
|
-
canPresentFromRootViewController:self.viewController
|
986
|
-
error:nil]) {
|
987
|
-
[self.appOpenAd
|
988
|
-
presentFromRootViewController:self.viewController];
|
989
|
-
} else {
|
990
|
-
[self fireEvent:@""
|
991
|
-
event:@"on.appOpenAd.failed.show"
|
992
|
-
withData:nil];
|
993
|
-
}
|
994
|
-
}
|
995
|
-
}];
|
996
|
-
});
|
997
|
-
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
998
|
-
}
|
999
|
-
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
1055
|
+
CDVPluginResult *pluginResult;
|
1056
|
+
NSString *callbackId = command.callbackId;
|
1057
|
+
NSDictionary *options = [command.arguments objectAtIndex:0];
|
1058
|
+
NSString *adUnitId = [options valueForKey:@"adUnitId"];
|
1059
|
+
BOOL autoShow = [[options valueForKey:@"autoShow"] boolValue];
|
1060
|
+
auto_Show = autoShow;
|
1061
|
+
adFormat = 1;
|
1062
|
+
self.appOpenAd = nil;
|
1063
|
+
if (adFormat == 1) {
|
1064
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
1065
|
+
GADRequest *request = [GADRequest request];
|
1066
|
+
GADExtras *extras = [[GADExtras alloc] init];
|
1067
|
+
// extras.additionalParameters = @{@"npa" : Npa}; // Deprecated
|
1068
|
+
[request registerAdNetworkExtras:extras];
|
1069
|
+
[GADAppOpenAd
|
1070
|
+
loadWithAdUnitID:adUnitId
|
1071
|
+
request:request
|
1072
|
+
completionHandler:^(GADAppOpenAd *ad, NSError *error) {
|
1073
|
+
if (error) {
|
1074
|
+
[self fireEvent:@""
|
1075
|
+
event:@"on.appOpenAd.failed.loaded"
|
1076
|
+
withData:nil];
|
1077
|
+
|
1078
|
+
return;
|
1079
|
+
}
|
1080
|
+
self.appOpenAd = ad;
|
1081
|
+
self.appOpenAd.fullScreenContentDelegate = self;
|
1082
|
+
[self fireEvent:@"" event:@"on.appOpenAd.loaded" withData:nil];
|
1083
|
+
if (auto_Show) {
|
1084
|
+
if (self.appOpenAd &&
|
1085
|
+
[self.appOpenAd
|
1086
|
+
canPresentFromRootViewController:self.viewController
|
1087
|
+
error:nil]) {
|
1088
|
+
[self.appOpenAd
|
1089
|
+
presentFromRootViewController:self.viewController];
|
1090
|
+
} else {
|
1091
|
+
[self fireEvent:@""
|
1092
|
+
event:@"on.appOpenAd.failed.show"
|
1093
|
+
withData:nil];
|
1094
|
+
}
|
1095
|
+
}
|
1096
|
+
}];
|
1097
|
+
});
|
1098
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
1099
|
+
}
|
1100
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
1000
1101
|
}
|
1001
1102
|
- (void)showAppOpenAd:(CDVInvokedUrlCommand *)command {
|
1002
|
-
|
1003
|
-
|
1004
|
-
|
1005
|
-
|
1006
|
-
|
1007
|
-
|
1008
|
-
|
1009
|
-
|
1010
|
-
|
1011
|
-
|
1012
|
-
|
1013
|
-
|
1014
|
-
|
1015
|
-
|
1016
|
-
|
1017
|
-
|
1018
|
-
|
1019
|
-
|
1020
|
-
|
1021
|
-
|
1022
|
-
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
1103
|
+
CDVPluginResult *pluginResult;
|
1104
|
+
NSString *callbackId = command.callbackId;
|
1105
|
+
if (self.appOpenAd &&
|
1106
|
+
[self.appOpenAd canPresentFromRootViewController:self.viewController
|
1107
|
+
error:nil]) {
|
1108
|
+
[self.appOpenAd presentFromRootViewController:self.viewController];
|
1109
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
1110
|
+
} else {
|
1111
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
|
1112
|
+
[self fireEvent:@""
|
1113
|
+
event:@"on."
|
1114
|
+
@"appO"
|
1115
|
+
@"penA"
|
1116
|
+
@"d."
|
1117
|
+
@"fail"
|
1118
|
+
@"ed."
|
1119
|
+
@"show"
|
1120
|
+
withData:nil];
|
1121
|
+
}
|
1122
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
1023
1123
|
}
|
1024
1124
|
- (void)loadInterstitialAd:(CDVInvokedUrlCommand *)command {
|
1025
|
-
|
1026
|
-
|
1027
|
-
|
1028
|
-
|
1029
|
-
|
1030
|
-
|
1031
|
-
|
1032
|
-
|
1033
|
-
|
1034
|
-
|
1035
|
-
|
1036
|
-
|
1037
|
-
|
1038
|
-
|
1039
|
-
|
1040
|
-
|
1041
|
-
|
1042
|
-
|
1043
|
-
|
1044
|
-
|
1045
|
-
|
1046
|
-
|
1047
|
-
|
1048
|
-
|
1049
|
-
|
1050
|
-
|
1051
|
-
|
1052
|
-
|
1053
|
-
@"l "
|
1054
|
-
@"ad"
|
1055
|
-
@" w"
|
1056
|
-
@"it"
|
1057
|
-
@"h "
|
1058
|
-
@"er"
|
1059
|
-
@"ro"
|
1060
|
-
@"r:"
|
1061
|
-
@" %"
|
1062
|
-
@"@",
|
1063
|
-
[error localizedDescription]);
|
1064
|
-
}
|
1065
|
-
self.interstitial = ad;
|
1066
|
-
self.interstitial.fullScreenContentDelegate = self;
|
1125
|
+
CDVPluginResult *pluginResult;
|
1126
|
+
NSString *callbackId = command.callbackId;
|
1127
|
+
NSDictionary *options = [command.arguments objectAtIndex:0];
|
1128
|
+
NSString *adUnitId = [options valueForKey:@"adUnitId"];
|
1129
|
+
BOOL autoShow = [[options valueForKey:@"autoShow"] boolValue];
|
1130
|
+
auto_Show = autoShow;
|
1131
|
+
adFormat = 2;
|
1132
|
+
if (adFormat == 2) {
|
1133
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
1134
|
+
GADRequest *request = [GADRequest request];
|
1135
|
+
[GADInterstitialAd
|
1136
|
+
loadWithAdUnitID:adUnitId
|
1137
|
+
request:request
|
1138
|
+
completionHandler:^(GADInterstitialAd *ad, NSError *error) {
|
1139
|
+
if (error) {
|
1140
|
+
|
1141
|
+
}
|
1142
|
+
self.interstitial = ad;
|
1143
|
+
self.interstitial.fullScreenContentDelegate = self;
|
1144
|
+
[self fireEvent:@"" event:@"on.interstitial.loaded" withData:nil];
|
1145
|
+
if (auto_Show) {
|
1146
|
+
if (self.interstitial &&
|
1147
|
+
[self.interstitial
|
1148
|
+
canPresentFromRootViewController:self.viewController
|
1149
|
+
error:nil]) {
|
1150
|
+
[self.interstitial
|
1151
|
+
presentFromRootViewController:self.viewController];
|
1152
|
+
} else {
|
1067
1153
|
[self fireEvent:@""
|
1068
|
-
event:@"on.interstitial.
|
1154
|
+
event:@"on.interstitial.failed.show"
|
1069
1155
|
withData:nil];
|
1070
|
-
|
1071
|
-
|
1072
|
-
|
1073
|
-
|
1074
|
-
|
1075
|
-
|
1076
|
-
|
1077
|
-
} else {
|
1078
|
-
[self fireEvent:@""
|
1079
|
-
event:@"on.interstitial.failed.show"
|
1080
|
-
withData:nil];
|
1081
|
-
}
|
1082
|
-
}
|
1083
|
-
}];
|
1084
|
-
});
|
1085
|
-
}
|
1086
|
-
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
1087
|
-
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
1156
|
+
}
|
1157
|
+
}
|
1158
|
+
}];
|
1159
|
+
});
|
1160
|
+
}
|
1161
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
1162
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
1088
1163
|
}
|
1089
1164
|
- (void)showInterstitialAd:(CDVInvokedUrlCommand *)command {
|
1090
|
-
|
1091
|
-
|
1092
|
-
|
1093
|
-
|
1094
|
-
|
1095
|
-
|
1096
|
-
|
1097
|
-
|
1098
|
-
|
1099
|
-
|
1100
|
-
|
1101
|
-
|
1102
|
-
|
1103
|
-
|
1104
|
-
|
1105
|
-
|
1106
|
-
|
1107
|
-
|
1108
|
-
|
1109
|
-
|
1110
|
-
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
1165
|
+
CDVPluginResult *pluginResult;
|
1166
|
+
NSString *callbackId = command.callbackId;
|
1167
|
+
if (self.interstitial &&
|
1168
|
+
[self.interstitial canPresentFromRootViewController:self.viewController
|
1169
|
+
error:nil]) {
|
1170
|
+
[self.interstitial presentFromRootViewController:self.viewController];
|
1171
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
1172
|
+
} else {
|
1173
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
|
1174
|
+
[self fireEvent:@""
|
1175
|
+
event:@"on."
|
1176
|
+
@"inte"
|
1177
|
+
@"rsti"
|
1178
|
+
@"tial"
|
1179
|
+
@".fai"
|
1180
|
+
@"led."
|
1181
|
+
@"show"
|
1182
|
+
withData:nil];
|
1183
|
+
}
|
1184
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
1111
1185
|
}
|
1112
1186
|
- (void)loadRewardedInterstitialAd:(CDVInvokedUrlCommand *)command {
|
1113
|
-
|
1114
|
-
|
1115
|
-
|
1116
|
-
|
1117
|
-
|
1118
|
-
|
1119
|
-
|
1120
|
-
|
1121
|
-
|
1122
|
-
|
1123
|
-
|
1124
|
-
|
1125
|
-
|
1126
|
-
|
1127
|
-
|
1128
|
-
|
1129
|
-
|
1130
|
-
|
1131
|
-
|
1132
|
-
|
1133
|
-
|
1134
|
-
|
1135
|
-
|
1136
|
-
|
1137
|
-
|
1138
|
-
|
1187
|
+
CDVPluginResult *pluginResult;
|
1188
|
+
NSString *callbackId = command.callbackId;
|
1189
|
+
|
1190
|
+
NSDictionary *options = [command.arguments objectAtIndex:0];
|
1191
|
+
NSString *adUnitId = [options valueForKey:@"adUnitId"];
|
1192
|
+
BOOL autoShow = [[options valueForKey:@"autoShow"] boolValue];
|
1193
|
+
|
1194
|
+
auto_Show = autoShow;
|
1195
|
+
adFormat = 4;
|
1196
|
+
if (adFormat == 4) {
|
1197
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
1198
|
+
GADRequest *request = [GADRequest request];
|
1199
|
+
[GADRewardedInterstitialAd
|
1200
|
+
loadWithAdUnitID:adUnitId
|
1201
|
+
request:request
|
1202
|
+
completionHandler:^(GADRewardedInterstitialAd *ad, NSError *error) {
|
1203
|
+
if (error) {
|
1204
|
+
/* NSLog(@"Rewarded ad failed to load with error: %@",
|
1205
|
+
[error localizedDescription]); */
|
1206
|
+
return;
|
1207
|
+
}
|
1208
|
+
self.rewardedInterstitialAd = ad;
|
1209
|
+
isAdSkip = 1;
|
1210
|
+
// NSLog(@"Rewarded ad loaded.");
|
1211
|
+
self.rewardedInterstitialAd.fullScreenContentDelegate = self;
|
1212
|
+
[self fireEvent:@"" event:@"on.rewardedInt.loaded" withData:nil];
|
1213
|
+
if (auto_Show) {
|
1214
|
+
if (self.rewardedInterstitialAd &&
|
1215
|
+
[self.rewardedInterstitialAd
|
1216
|
+
canPresentFromRootViewController:self.viewController
|
1217
|
+
error:nil]) {
|
1218
|
+
[self.rewardedInterstitialAd
|
1219
|
+
presentFromRootViewController:self.viewController
|
1220
|
+
userDidEarnRewardHandler:^{
|
1221
|
+
GADAdReward *reward =
|
1222
|
+
self.rewardedInterstitialAd.adReward;
|
1223
|
+
[self fireEvent:@""
|
1224
|
+
event:@"on.rewardedInt."
|
1225
|
+
@"userEarnedReward"
|
1226
|
+
withData:nil];
|
1227
|
+
isAdSkip = 2;
|
1228
|
+
NSString *rewardMessage = [NSString
|
1229
|
+
stringWithFormat:@"Reward received with "
|
1230
|
+
@"currency %@ , amount %ld",
|
1231
|
+
reward.type,
|
1232
|
+
[reward.amount longValue]];
|
1233
|
+
NSLog(@"%@", rewardMessage);
|
1234
|
+
}];
|
1235
|
+
} else {
|
1139
1236
|
[self fireEvent:@""
|
1140
|
-
event:@"on.rewardedInt.
|
1237
|
+
event:@"on.rewardedInt.failed.show"
|
1141
1238
|
withData:nil];
|
1142
|
-
|
1143
|
-
|
1144
|
-
|
1145
|
-
|
1146
|
-
|
1147
|
-
|
1148
|
-
|
1149
|
-
userDidEarnRewardHandler:^{
|
1150
|
-
GADAdReward *reward =
|
1151
|
-
self.rewardedInterstitialAd.adReward;
|
1152
|
-
[self fireEvent:@""
|
1153
|
-
event:@"on.rewardedInt."
|
1154
|
-
@"userEarnedReward"
|
1155
|
-
withData:nil];
|
1156
|
-
isAdSkip = 2;
|
1157
|
-
NSString *rewardMessage = [NSString
|
1158
|
-
stringWithFormat:
|
1159
|
-
@"Reward received with "
|
1160
|
-
@"currency %@ , amount %ld",
|
1161
|
-
reward.type,
|
1162
|
-
[reward.amount longValue]];
|
1163
|
-
NSLog(@"%@", rewardMessage);
|
1164
|
-
}];
|
1165
|
-
} else {
|
1166
|
-
[self fireEvent:@""
|
1167
|
-
event:@"on.rewardedInt.failed.show"
|
1168
|
-
withData:nil];
|
1169
|
-
}
|
1170
|
-
}
|
1171
|
-
}];
|
1172
|
-
});
|
1173
|
-
}
|
1174
|
-
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
1175
|
-
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
1239
|
+
}
|
1240
|
+
}
|
1241
|
+
}];
|
1242
|
+
});
|
1243
|
+
}
|
1244
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
1245
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
1176
1246
|
}
|
1177
1247
|
- (void)showRewardedInterstitialAd:(CDVInvokedUrlCommand *)command {
|
1178
|
-
|
1179
|
-
|
1180
|
-
|
1181
|
-
|
1182
|
-
|
1183
|
-
|
1184
|
-
|
1185
|
-
|
1186
|
-
|
1187
|
-
|
1188
|
-
|
1189
|
-
|
1190
|
-
|
1191
|
-
|
1192
|
-
|
1193
|
-
|
1194
|
-
|
1195
|
-
|
1196
|
-
|
1197
|
-
|
1198
|
-
|
1199
|
-
|
1200
|
-
|
1201
|
-
|
1202
|
-
|
1203
|
-
|
1204
|
-
|
1205
|
-
|
1206
|
-
|
1207
|
-
|
1208
|
-
|
1209
|
-
|
1210
|
-
|
1211
|
-
|
1212
|
-
|
1213
|
-
|
1214
|
-
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
1248
|
+
CDVPluginResult *pluginResult;
|
1249
|
+
NSString *callbackId = command.callbackId;
|
1250
|
+
if (self.rewardedInterstitialAd &&
|
1251
|
+
[self.rewardedInterstitialAd
|
1252
|
+
canPresentFromRootViewController:self.viewController
|
1253
|
+
error:nil]) {
|
1254
|
+
[self.rewardedInterstitialAd
|
1255
|
+
presentFromRootViewController:self.viewController
|
1256
|
+
userDidEarnRewardHandler:^{
|
1257
|
+
GADAdReward *reward = self.rewardedInterstitialAd.adReward;
|
1258
|
+
[self fireEvent:@""
|
1259
|
+
event:@"on.rewardedInt.userEarnedReward"
|
1260
|
+
withData:nil];
|
1261
|
+
isAdSkip = 2;
|
1262
|
+
NSString *rewardMessage = [NSString
|
1263
|
+
stringWithFormat:@"Reward received with "
|
1264
|
+
@"currency %@ , amount %ld",
|
1265
|
+
reward.type, [reward.amount longValue]];
|
1266
|
+
NSLog(@"%"
|
1267
|
+
@"@",
|
1268
|
+
rewardMessage);
|
1269
|
+
}];
|
1270
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
1271
|
+
} else {
|
1272
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
|
1273
|
+
[self fireEvent:@""
|
1274
|
+
event:@"on."
|
1275
|
+
@"rewa"
|
1276
|
+
@"rded"
|
1277
|
+
@"Int."
|
1278
|
+
@"fail"
|
1279
|
+
@"ed."
|
1280
|
+
@"show"
|
1281
|
+
withData:nil];
|
1282
|
+
}
|
1283
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
1215
1284
|
}
|
1216
1285
|
- (void)loadRewardedAd:(CDVInvokedUrlCommand *)command {
|
1217
|
-
|
1218
|
-
|
1219
|
-
|
1220
|
-
|
1221
|
-
|
1222
|
-
|
1223
|
-
|
1224
|
-
|
1225
|
-
|
1226
|
-
|
1227
|
-
|
1228
|
-
|
1229
|
-
|
1230
|
-
|
1231
|
-
|
1232
|
-
|
1233
|
-
|
1234
|
-
|
1235
|
-
|
1236
|
-
|
1237
|
-
|
1238
|
-
|
1239
|
-
|
1240
|
-
|
1241
|
-
|
1242
|
-
|
1243
|
-
|
1244
|
-
|
1245
|
-
|
1246
|
-
|
1247
|
-
|
1286
|
+
CDVPluginResult *pluginResult;
|
1287
|
+
NSString *callbackId = command.callbackId;
|
1288
|
+
NSDictionary *options = [command.arguments objectAtIndex:0];
|
1289
|
+
NSString *adUnitId = [options valueForKey:@"adUnitId"];
|
1290
|
+
BOOL autoShow = [[options valueForKey:@"autoShow"] boolValue];
|
1291
|
+
auto_Show = autoShow;
|
1292
|
+
adFormat = 3;
|
1293
|
+
if (adFormat == 3) {
|
1294
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
1295
|
+
GADRequest *request = [GADRequest request];
|
1296
|
+
[GADRewardedAd
|
1297
|
+
loadWithAdUnitID:adUnitId
|
1298
|
+
request:request
|
1299
|
+
completionHandler:^(GADRewardedAd *ad, NSError *error) {
|
1300
|
+
if (error) {
|
1301
|
+
/* NSLog(@"Rewarded ad failed to load with error: %@",
|
1302
|
+
[error localizedDescription]); */
|
1303
|
+
return;
|
1304
|
+
}
|
1305
|
+
self.rewardedAd = ad;
|
1306
|
+
// NSLog(@"Rewarded ad loaded.");
|
1307
|
+
isAdSkip = 0;
|
1308
|
+
self.rewardedAd.fullScreenContentDelegate = self;
|
1309
|
+
[self fireEvent:@"" event:@"on.rewarded.loaded" withData:nil];
|
1310
|
+
if (auto_Show) {
|
1311
|
+
if (self.rewardedAd &&
|
1312
|
+
[self.rewardedAd
|
1313
|
+
canPresentFromRootViewController:self.viewController
|
1314
|
+
error:nil]) {
|
1315
|
+
[self.rewardedAd
|
1316
|
+
presentFromRootViewController:self.viewController
|
1248
1317
|
userDidEarnRewardHandler:^{
|
1249
|
-
|
1250
|
-
|
1251
|
-
|
1252
|
-
|
1253
|
-
|
1254
|
-
|
1255
|
-
|
1256
|
-
|
1257
|
-
|
1258
|
-
|
1259
|
-
|
1260
|
-
|
1261
|
-
|
1262
|
-
|
1263
|
-
|
1264
|
-
|
1265
|
-
|
1266
|
-
|
1267
|
-
|
1268
|
-
|
1269
|
-
|
1270
|
-
|
1271
|
-
|
1272
|
-
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
1273
|
-
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
1318
|
+
GADAdReward *reward = self.rewardedAd.adReward;
|
1319
|
+
[self fireEvent:@""
|
1320
|
+
event:@"on.reward.userEarnedReward"
|
1321
|
+
withData:nil];
|
1322
|
+
isAdSkip = 2;
|
1323
|
+
NSString *rewardMessage = [NSString
|
1324
|
+
stringWithFormat:
|
1325
|
+
@"Reward received with currency "
|
1326
|
+
@"%@ , amount %lf",
|
1327
|
+
reward.type, [reward.amount doubleValue]];
|
1328
|
+
NSLog(@"%@", rewardMessage);
|
1329
|
+
}];
|
1330
|
+
} else {
|
1331
|
+
[self fireEvent:@""
|
1332
|
+
event:@"on.rewarded.failed.show"
|
1333
|
+
withData:nil];
|
1334
|
+
}
|
1335
|
+
}
|
1336
|
+
}];
|
1337
|
+
});
|
1338
|
+
}
|
1339
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
1340
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
1274
1341
|
}
|
1275
1342
|
- (void)showRewardedAd:(CDVInvokedUrlCommand *)command {
|
1276
|
-
|
1277
|
-
|
1278
|
-
|
1279
|
-
|
1280
|
-
|
1281
|
-
|
1282
|
-
|
1283
|
-
|
1284
|
-
|
1285
|
-
|
1286
|
-
|
1287
|
-
|
1288
|
-
|
1289
|
-
|
1290
|
-
|
1291
|
-
|
1292
|
-
|
1293
|
-
|
1294
|
-
|
1295
|
-
|
1296
|
-
|
1297
|
-
|
1298
|
-
|
1299
|
-
|
1300
|
-
|
1301
|
-
|
1302
|
-
|
1303
|
-
|
1304
|
-
|
1305
|
-
|
1306
|
-
|
1307
|
-
|
1308
|
-
|
1309
|
-
|
1310
|
-
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
1343
|
+
CDVPluginResult *pluginResult;
|
1344
|
+
NSString *callbackId = command.callbackId;
|
1345
|
+
if (self.rewardedAd &&
|
1346
|
+
[self.rewardedAd canPresentFromRootViewController:self.viewController
|
1347
|
+
error:nil]) {
|
1348
|
+
[self.rewardedAd
|
1349
|
+
presentFromRootViewController:self.viewController
|
1350
|
+
userDidEarnRewardHandler:^{
|
1351
|
+
GADAdReward *reward = self.rewardedAd.adReward;
|
1352
|
+
[self fireEvent:@""
|
1353
|
+
event:@"on.reward.userEarnedReward"
|
1354
|
+
withData:nil];
|
1355
|
+
isAdSkip = 2;
|
1356
|
+
NSString *rewardMessage = [NSString
|
1357
|
+
stringWithFormat:
|
1358
|
+
@"Reward received with currency %@ , amount %lf",
|
1359
|
+
reward.type, [reward.amount doubleValue]];
|
1360
|
+
NSLog(@"%"
|
1361
|
+
@"@",
|
1362
|
+
rewardMessage);
|
1363
|
+
}];
|
1364
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
1365
|
+
} else {
|
1366
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
|
1367
|
+
[self fireEvent:@""
|
1368
|
+
event:@"on."
|
1369
|
+
@"rewa"
|
1370
|
+
@"rded"
|
1371
|
+
@".fai"
|
1372
|
+
@"led."
|
1373
|
+
@"show"
|
1374
|
+
withData:nil];
|
1375
|
+
}
|
1376
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
1311
1377
|
}
|
1312
1378
|
- (void)fireEvent:(NSString *)obj
|
1313
1379
|
event:(NSString *)eventName
|
1314
1380
|
withData:(NSString *)jsonStr {
|
1315
|
-
|
1316
|
-
|
1317
|
-
|
1318
|
-
|
1319
|
-
|
1320
|
-
|
1321
|
-
|
1322
|
-
|
1323
|
-
|
1324
|
-
|
1325
|
-
|
1326
|
-
|
1327
|
-
|
1328
|
-
|
1329
|
-
|
1330
|
-
|
1331
|
-
|
1332
|
-
|
1333
|
-
|
1334
|
-
|
1335
|
-
|
1336
|
-
|
1337
|
-
|
1338
|
-
|
1339
|
-
|
1340
|
-
|
1341
|
-
|
1342
|
-
|
1343
|
-
|
1344
|
-
|
1345
|
-
|
1346
|
-
|
1347
|
-
|
1348
|
-
|
1349
|
-
|
1350
|
-
|
1351
|
-
|
1352
|
-
|
1353
|
-
|
1354
|
-
|
1355
|
-
|
1356
|
-
|
1357
|
-
|
1381
|
+
NSString *js;
|
1382
|
+
if (obj && [obj isEqualToString:@"windo"
|
1383
|
+
@"w"]) {
|
1384
|
+
js = [NSString stringWithFormat:@"var "
|
1385
|
+
@"evt="
|
1386
|
+
@"document"
|
1387
|
+
@".createE"
|
1388
|
+
@"vent("
|
1389
|
+
@"\"UIEven"
|
1390
|
+
@"ts\");"
|
1391
|
+
@"evt."
|
1392
|
+
@"initUIEv"
|
1393
|
+
@"ent("
|
1394
|
+
@"\"%@\","
|
1395
|
+
@"true,"
|
1396
|
+
@"false,"
|
1397
|
+
@"window,"
|
1398
|
+
@"0);"
|
1399
|
+
@"window."
|
1400
|
+
@"dispatch"
|
1401
|
+
@"Event("
|
1402
|
+
@"evt);",
|
1403
|
+
eventName];
|
1404
|
+
} else if (jsonStr && [jsonStr length] > 0) {
|
1405
|
+
js = [NSString stringWithFormat:@"javascri"
|
1406
|
+
@"pt:"
|
1407
|
+
@"cordova."
|
1408
|
+
@"fireDocu"
|
1409
|
+
@"mentEven"
|
1410
|
+
@"t('%@',%"
|
1411
|
+
@"@);",
|
1412
|
+
eventName, jsonStr];
|
1413
|
+
} else {
|
1414
|
+
js = [NSString stringWithFormat:@"javascri"
|
1415
|
+
@"pt:"
|
1416
|
+
@"cordova."
|
1417
|
+
@"fireDocu"
|
1418
|
+
@"mentEven"
|
1419
|
+
@"t('%@')"
|
1420
|
+
@";",
|
1421
|
+
eventName];
|
1422
|
+
}
|
1423
|
+
[self.commandDelegate evalJs:js];
|
1358
1424
|
}
|
1359
1425
|
|
1360
1426
|
- (NSString *)__getAdMobDeviceId {
|
1361
|
-
|
1362
|
-
|
1427
|
+
NSUUID *adid = [[ASIdentifierManager sharedManager] advertisingIdentifier];
|
1428
|
+
return [self __sha256:adid.UUIDString];
|
1363
1429
|
}
|
1364
1430
|
|
1365
|
-
- (NSString *)
|
1366
|
-
|
1367
|
-
|
1368
|
-
|
1369
|
-
|
1370
|
-
|
1371
|
-
|
1372
|
-
|
1373
|
-
|
1374
|
-
|
1375
|
-
|
1376
|
-
|
1377
|
-
|
1378
|
-
|
1379
|
-
|
1380
|
-
return hexString;
|
1431
|
+
- (NSString *)__sha256:(NSString *)string {
|
1432
|
+
CC_SHA256_CTX sha256Context;
|
1433
|
+
CC_SHA256_Init(&sha256Context);
|
1434
|
+
NSData *data = [string dataUsingEncoding:NSUTF8StringEncoding];
|
1435
|
+
CC_SHA256_Update(&sha256Context, [data bytes], (CC_LONG)[data length]);
|
1436
|
+
unsigned char digest[CC_SHA256_DIGEST_LENGTH];
|
1437
|
+
CC_SHA256_Final(digest, &sha256Context);
|
1438
|
+
|
1439
|
+
NSMutableString *hexString =
|
1440
|
+
[NSMutableString stringWithCapacity:(CC_SHA256_DIGEST_LENGTH * 2)];
|
1441
|
+
for (int i = 0; i < CC_SHA256_DIGEST_LENGTH; i++) {
|
1442
|
+
[hexString appendFormat:@"%02x", digest[i]];
|
1443
|
+
}
|
1444
|
+
|
1445
|
+
return hexString;
|
1381
1446
|
}
|
1382
1447
|
|
1383
1448
|
#pragma mark GADBannerViewDelegate implementation
|
1384
1449
|
- (void)bannerViewDidReceiveAd:(GADBannerView *)bannerView {
|
1385
|
-
|
1386
|
-
|
1387
|
-
|
1388
|
-
|
1389
|
-
|
1390
|
-
|
1391
|
-
|
1392
|
-
|
1393
|
-
|
1394
|
-
|
1395
|
-
|
1450
|
+
|
1451
|
+
NSString *collapsibleStatus =
|
1452
|
+
bannerView.isCollapsible ? @"collapsible" : @"not collapsible";
|
1453
|
+
NSDictionary *eventData = @{@"collapsible" : collapsibleStatus};
|
1454
|
+
NSError *error;
|
1455
|
+
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:eventData
|
1456
|
+
options:0
|
1457
|
+
error:&error];
|
1458
|
+
|
1459
|
+
if (!jsonData) {
|
1460
|
+
// NSLog(@"Failed to serialize event data: %@", error);
|
1461
|
+
} else {
|
1462
|
+
NSString *jsonString = [[NSString alloc] initWithData:jsonData
|
1463
|
+
encoding:NSUTF8StringEncoding];
|
1464
|
+
[self fireEvent:@"" event:@"on.is.collapsible" withData:jsonString];
|
1465
|
+
}
|
1466
|
+
|
1467
|
+
[self fireEvent:@""
|
1468
|
+
event:@"on."
|
1469
|
+
@"banner"
|
1470
|
+
@".load"
|
1471
|
+
withData:nil];
|
1472
|
+
|
1473
|
+
if (auto_Show) {
|
1474
|
+
if (self.bannerView) {
|
1475
|
+
[self addBannerViewToView:command];
|
1476
|
+
self.bannerView.hidden = NO;
|
1396
1477
|
}
|
1397
|
-
|
1478
|
+
} else {
|
1398
1479
|
[self fireEvent:@""
|
1399
1480
|
event:@"on."
|
1400
|
-
|
1401
|
-
|
1481
|
+
@"bann"
|
1482
|
+
@"er."
|
1483
|
+
@"fail"
|
1484
|
+
@"ed."
|
1485
|
+
@"show"
|
1402
1486
|
withData:nil];
|
1403
|
-
|
1404
|
-
@"eceiveAd");
|
1405
|
-
if (auto_Show) {
|
1406
|
-
if (self.bannerView) {
|
1407
|
-
[self addBannerViewToView:command];
|
1408
|
-
self.bannerView.hidden = NO;
|
1409
|
-
}
|
1410
|
-
} else {
|
1411
|
-
[self fireEvent:@""
|
1412
|
-
event:@"on."
|
1413
|
-
@"bann"
|
1414
|
-
@"er."
|
1415
|
-
@"fail"
|
1416
|
-
@"ed."
|
1417
|
-
@"show"
|
1418
|
-
withData:nil];
|
1419
|
-
}
|
1487
|
+
}
|
1420
1488
|
}
|
1421
1489
|
- (void)bannerView:(GADBannerView *)bannerView
|
1422
|
-
didFailToReceiveAdWithError:(NSError *)error {
|
1423
|
-
|
1424
|
-
|
1425
|
-
|
1426
|
-
|
1427
|
-
|
1428
|
-
|
1429
|
-
|
1430
|
-
@"didFailToRecei"
|
1431
|
-
@"veAdWithError:"
|
1432
|
-
@" %@",
|
1433
|
-
[error localizedDescription]);
|
1490
|
+
didFailToReceiveAdWithError:(NSError *)error {
|
1491
|
+
[self fireEvent:@""
|
1492
|
+
event:@"on."
|
1493
|
+
@"banner"
|
1494
|
+
@".faile"
|
1495
|
+
@"d.load"
|
1496
|
+
withData:nil];
|
1497
|
+
|
1434
1498
|
}
|
1435
1499
|
- (void)bannerViewDidRecordImpression:(GADBannerView *)bannerView {
|
1500
|
+
[self fireEvent:@""
|
1501
|
+
event:@"on."
|
1502
|
+
@"banner"
|
1503
|
+
@".impre"
|
1504
|
+
@"ssion"
|
1505
|
+
withData:nil];
|
1506
|
+
|
1507
|
+
}
|
1508
|
+
- (void)bannerViewWillPresentScreen:(GADBannerView *)bannerView {
|
1509
|
+
[self fireEvent:@""
|
1510
|
+
event:@"on."
|
1511
|
+
@"banner"
|
1512
|
+
@".open"
|
1513
|
+
withData:nil];
|
1514
|
+
|
1515
|
+
}
|
1516
|
+
- (void)bannerViewWillDismissScreen:(GADBannerView *)bannerView {
|
1517
|
+
[self fireEvent:@""
|
1518
|
+
event:@"on."
|
1519
|
+
@"banner"
|
1520
|
+
@".close"
|
1521
|
+
withData:nil];
|
1522
|
+
|
1523
|
+
}
|
1524
|
+
- (void)bannerViewDidDismissScreen:(GADBannerView *)bannerView {
|
1525
|
+
[self fireEvent:@""
|
1526
|
+
event:@"on."
|
1527
|
+
@"banner"
|
1528
|
+
@".did."
|
1529
|
+
@"dismis"
|
1530
|
+
@"s"
|
1531
|
+
withData:nil];
|
1532
|
+
|
1533
|
+
}
|
1534
|
+
#pragma GADFullScreeContentDelegate implementation
|
1535
|
+
- (void)adWillPresentFullScreenContent:(id)ad {
|
1536
|
+
if (adFormat == 1) {
|
1436
1537
|
[self fireEvent:@""
|
1437
1538
|
event:@"on."
|
1438
|
-
|
1439
|
-
|
1440
|
-
|
1539
|
+
@"appO"
|
1540
|
+
@"penA"
|
1541
|
+
@"d."
|
1542
|
+
@"show"
|
1441
1543
|
withData:nil];
|
1442
|
-
|
1443
|
-
@"
|
1444
|
-
@"
|
1445
|
-
|
1446
|
-
|
1544
|
+
/* NSLog(@"Ad will "
|
1545
|
+
@"present "
|
1546
|
+
@"full screen "
|
1547
|
+
@"content App "
|
1548
|
+
@"Open Ad.");
|
1549
|
+
*/
|
1550
|
+
} else if (adFormat == 2) {
|
1447
1551
|
[self fireEvent:@""
|
1448
1552
|
event:@"on."
|
1449
|
-
|
1450
|
-
|
1553
|
+
@"inte"
|
1554
|
+
@"rsti"
|
1555
|
+
@"tial"
|
1556
|
+
@".sho"
|
1557
|
+
@"w"
|
1451
1558
|
withData:nil];
|
1452
|
-
|
1453
|
-
|
1454
|
-
|
1455
|
-
|
1456
|
-
|
1559
|
+
[self fireEvent:@""
|
1560
|
+
event:@"onPr"
|
1561
|
+
@"esen"
|
1562
|
+
@"tAd"
|
1563
|
+
withData:nil];
|
1564
|
+
/* NSLog(@"Ad will "
|
1565
|
+
@"present "
|
1566
|
+
@"full screen "
|
1567
|
+
@"content "
|
1568
|
+
@"interstitial"
|
1569
|
+
@"."); */
|
1570
|
+
} else if (adFormat == 3) {
|
1457
1571
|
[self fireEvent:@""
|
1458
1572
|
event:@"on."
|
1459
|
-
|
1460
|
-
|
1573
|
+
@"rewa"
|
1574
|
+
@"rded"
|
1575
|
+
@".sho"
|
1576
|
+
@"w"
|
1461
1577
|
withData:nil];
|
1462
|
-
|
1463
|
-
|
1464
|
-
@"
|
1465
|
-
|
1466
|
-
|
1578
|
+
isAdSkip = 1;
|
1579
|
+
/* NSLog(@"Ad will "
|
1580
|
+
@"present "
|
1581
|
+
@"full screen "
|
1582
|
+
@"content "
|
1583
|
+
@"rewarded."); */
|
1584
|
+
} else if (adFormat == 4) {
|
1585
|
+
isAdSkip = 1;
|
1467
1586
|
[self fireEvent:@""
|
1468
1587
|
event:@"on."
|
1469
|
-
|
1470
|
-
|
1471
|
-
|
1472
|
-
|
1588
|
+
@"rewa"
|
1589
|
+
@"rded"
|
1590
|
+
@"Int."
|
1591
|
+
@"show"
|
1592
|
+
@"ed"
|
1473
1593
|
withData:nil];
|
1474
|
-
|
1475
|
-
@"
|
1476
|
-
|
1477
|
-
|
1478
|
-
|
1479
|
-
|
1480
|
-
|
1481
|
-
event:@"on."
|
1482
|
-
@"appO"
|
1483
|
-
@"penA"
|
1484
|
-
@"d."
|
1485
|
-
@"show"
|
1486
|
-
withData:nil];
|
1487
|
-
NSLog(@"Ad will "
|
1488
|
-
@"present "
|
1489
|
-
@"full screen "
|
1490
|
-
@"content App "
|
1491
|
-
@"Open Ad.");
|
1492
|
-
} else if (adFormat == 2) {
|
1493
|
-
[self fireEvent:@""
|
1494
|
-
event:@"on."
|
1495
|
-
@"inte"
|
1496
|
-
@"rsti"
|
1497
|
-
@"tial"
|
1498
|
-
@".sho"
|
1499
|
-
@"w"
|
1500
|
-
withData:nil];
|
1501
|
-
[self fireEvent:@""
|
1502
|
-
event:@"onPr"
|
1503
|
-
@"esen"
|
1504
|
-
@"tAd"
|
1505
|
-
withData:nil];
|
1506
|
-
NSLog(@"Ad will "
|
1507
|
-
@"present "
|
1508
|
-
@"full screen "
|
1509
|
-
@"content "
|
1510
|
-
@"interstitial"
|
1511
|
-
@".");
|
1512
|
-
} else if (adFormat == 3) {
|
1513
|
-
[self fireEvent:@""
|
1514
|
-
event:@"on."
|
1515
|
-
@"rewa"
|
1516
|
-
@"rded"
|
1517
|
-
@".sho"
|
1518
|
-
@"w"
|
1519
|
-
withData:nil];
|
1520
|
-
isAdSkip = 1;
|
1521
|
-
NSLog(@"Ad will "
|
1522
|
-
@"present "
|
1523
|
-
@"full screen "
|
1524
|
-
@"content "
|
1525
|
-
@"rewarded.");
|
1526
|
-
} else if (adFormat == 4) {
|
1527
|
-
isAdSkip = 1;
|
1528
|
-
[self fireEvent:@""
|
1529
|
-
event:@"on."
|
1530
|
-
@"rewa"
|
1531
|
-
@"rded"
|
1532
|
-
@"Int."
|
1533
|
-
@"show"
|
1534
|
-
@"ed"
|
1535
|
-
withData:nil];
|
1536
|
-
NSLog(@"Ad will "
|
1537
|
-
@"present "
|
1538
|
-
@"full screen "
|
1539
|
-
@"content "
|
1540
|
-
@"interstitial"
|
1541
|
-
@" rewarded.");
|
1542
|
-
}
|
1594
|
+
/* NSLog(@"Ad will "
|
1595
|
+
@"present "
|
1596
|
+
@"full screen "
|
1597
|
+
@"content "
|
1598
|
+
@"interstitial"
|
1599
|
+
@" rewarded."); */
|
1600
|
+
}
|
1543
1601
|
}
|
1544
1602
|
- (void)ad:(id)ad didFailToPresentFullScreenContentWithError:(NSError *)error {
|
1545
|
-
|
1546
|
-
|
1547
|
-
|
1548
|
-
|
1549
|
-
|
1550
|
-
|
1551
|
-
|
1552
|
-
|
1553
|
-
|
1554
|
-
|
1555
|
-
|
1556
|
-
|
1557
|
-
|
1558
|
-
|
1559
|
-
|
1560
|
-
|
1561
|
-
|
1562
|
-
|
1563
|
-
|
1564
|
-
|
1565
|
-
|
1566
|
-
|
1567
|
-
|
1568
|
-
|
1569
|
-
|
1570
|
-
|
1571
|
-
|
1572
|
-
|
1573
|
-
|
1574
|
-
|
1575
|
-
|
1576
|
-
|
1577
|
-
|
1578
|
-
|
1579
|
-
|
1580
|
-
|
1581
|
-
|
1582
|
-
|
1583
|
-
|
1584
|
-
|
1585
|
-
|
1586
|
-
|
1587
|
-
|
1588
|
-
|
1589
|
-
|
1590
|
-
|
1591
|
-
|
1592
|
-
|
1593
|
-
|
1594
|
-
|
1595
|
-
|
1596
|
-
|
1597
|
-
|
1598
|
-
|
1599
|
-
|
1600
|
-
|
1601
|
-
|
1602
|
-
|
1603
|
-
|
1604
|
-
|
1605
|
-
|
1606
|
-
|
1607
|
-
|
1608
|
-
|
1609
|
-
|
1610
|
-
|
1611
|
-
|
1612
|
-
|
1613
|
-
|
1614
|
-
|
1615
|
-
|
1616
|
-
|
1617
|
-
|
1618
|
-
|
1619
|
-
|
1603
|
+
if (adFormat == 1) {
|
1604
|
+
[self fireEvent:@""
|
1605
|
+
event:@"on."
|
1606
|
+
@"appO"
|
1607
|
+
@"penA"
|
1608
|
+
@"d."
|
1609
|
+
@"fail"
|
1610
|
+
@"ed."
|
1611
|
+
@"load"
|
1612
|
+
@"ed"
|
1613
|
+
withData:nil];
|
1614
|
+
/* NSLog(@"Ad failed "
|
1615
|
+
@"to present "
|
1616
|
+
@"full screen "
|
1617
|
+
@"content "
|
1618
|
+
@"with error "
|
1619
|
+
@"App Open Ad "
|
1620
|
+
@"%@.",
|
1621
|
+
[error localizedDescription]); */
|
1622
|
+
} else if (adFormat == 2) {
|
1623
|
+
[self fireEvent:@""
|
1624
|
+
event:@"on."
|
1625
|
+
@"inte"
|
1626
|
+
@"rsti"
|
1627
|
+
@"tial"
|
1628
|
+
@".fai"
|
1629
|
+
@"led."
|
1630
|
+
@"load"
|
1631
|
+
withData:nil];
|
1632
|
+
/* NSLog(@"Ad failed "
|
1633
|
+
@"to present "
|
1634
|
+
@"full screen "
|
1635
|
+
@"content "
|
1636
|
+
@"with error "
|
1637
|
+
@"interstitial"
|
1638
|
+
@" %@.",
|
1639
|
+
[error localizedDescription]); */
|
1640
|
+
} else if (adFormat == 3) {
|
1641
|
+
[self fireEvent:@""
|
1642
|
+
event:@"on."
|
1643
|
+
@"rewa"
|
1644
|
+
@"rded"
|
1645
|
+
@".fai"
|
1646
|
+
@"led."
|
1647
|
+
@"load"
|
1648
|
+
withData:nil];
|
1649
|
+
/* NSLog(@"Ad failed "
|
1650
|
+
@"to present "
|
1651
|
+
@"full screen "
|
1652
|
+
@"content "
|
1653
|
+
@"with error "
|
1654
|
+
@"rewarded "
|
1655
|
+
@"%@.",
|
1656
|
+
[error localizedDescription]); */
|
1657
|
+
} else if (adFormat == 4) {
|
1658
|
+
[self fireEvent:@""
|
1659
|
+
event:@"on."
|
1660
|
+
@"rewa"
|
1661
|
+
@"rded"
|
1662
|
+
@"Int."
|
1663
|
+
@"fail"
|
1664
|
+
@"ed."
|
1665
|
+
@"load"
|
1666
|
+
withData:nil];
|
1667
|
+
/* NSLog(@"Ad failed "
|
1668
|
+
@"to present "
|
1669
|
+
@"full screen "
|
1670
|
+
@"content "
|
1671
|
+
@"with error "
|
1672
|
+
@"interstitial"
|
1673
|
+
@" "
|
1674
|
+
@"rewarded "
|
1675
|
+
@"%@.",
|
1676
|
+
[error localizedDescription]); */
|
1677
|
+
}
|
1620
1678
|
}
|
1621
1679
|
|
1622
1680
|
- (void)adDidDismissFullScreenContent:(id)ad {
|
1623
|
-
|
1624
|
-
|
1625
|
-
|
1626
|
-
|
1627
|
-
|
1628
|
-
|
1629
|
-
|
1630
|
-
|
1631
|
-
|
1632
|
-
|
1633
|
-
|
1634
|
-
|
1635
|
-
|
1636
|
-
|
1637
|
-
|
1638
|
-
|
1639
|
-
|
1640
|
-
|
1641
|
-
|
1642
|
-
|
1643
|
-
|
1644
|
-
|
1645
|
-
|
1646
|
-
|
1647
|
-
|
1648
|
-
|
1649
|
-
|
1650
|
-
|
1651
|
-
|
1652
|
-
|
1653
|
-
|
1654
|
-
|
1655
|
-
|
1656
|
-
|
1657
|
-
|
1658
|
-
|
1659
|
-
|
1660
|
-
|
1661
|
-
|
1662
|
-
|
1663
|
-
|
1664
|
-
|
1665
|
-
|
1666
|
-
|
1667
|
-
|
1668
|
-
|
1669
|
-
|
1670
|
-
|
1671
|
-
|
1672
|
-
|
1673
|
-
|
1674
|
-
|
1675
|
-
|
1676
|
-
|
1677
|
-
|
1678
|
-
|
1679
|
-
|
1680
|
-
|
1681
|
-
|
1682
|
-
|
1683
|
-
|
1684
|
-
|
1685
|
-
|
1686
|
-
|
1687
|
-
|
1688
|
-
|
1689
|
-
|
1690
|
-
|
1691
|
-
|
1692
|
-
|
1693
|
-
|
1694
|
-
|
1695
|
-
|
1696
|
-
|
1697
|
-
}
|
1698
|
-
[self fireEvent:@""
|
1699
|
-
event:@"on."
|
1700
|
-
@"rewa"
|
1701
|
-
@"rded"
|
1702
|
-
@"Int."
|
1703
|
-
@"dism"
|
1704
|
-
@"isse"
|
1705
|
-
@"d"
|
1706
|
-
withData:nil];
|
1707
|
-
NSLog(@"Ad did "
|
1708
|
-
@"dismiss "
|
1709
|
-
@"full screen "
|
1710
|
-
@"content "
|
1711
|
-
@"interstitial"
|
1712
|
-
@" rewarded.");
|
1681
|
+
if (adFormat == 1) {
|
1682
|
+
[self fireEvent:@""
|
1683
|
+
event:@"on."
|
1684
|
+
@"appO"
|
1685
|
+
@"penA"
|
1686
|
+
@"d."
|
1687
|
+
@"dism"
|
1688
|
+
@"isse"
|
1689
|
+
@"d"
|
1690
|
+
withData:nil];
|
1691
|
+
/* NSLog(@"Ad did "
|
1692
|
+
@"dismiss "
|
1693
|
+
@"full screen "
|
1694
|
+
@"content App "
|
1695
|
+
@"Open Ad."); */
|
1696
|
+
} else if (adFormat == 2) {
|
1697
|
+
[self fireEvent:@""
|
1698
|
+
event:@"on."
|
1699
|
+
@"inte"
|
1700
|
+
@"rsti"
|
1701
|
+
@"tial"
|
1702
|
+
@".dis"
|
1703
|
+
@"miss"
|
1704
|
+
@"ed"
|
1705
|
+
withData:nil];
|
1706
|
+
/* NSLog(@"Ad did "
|
1707
|
+
@"dismiss "
|
1708
|
+
@"full screen "
|
1709
|
+
@"content "
|
1710
|
+
@"interstitial"
|
1711
|
+
@"."); */
|
1712
|
+
} else if (adFormat == 3) {
|
1713
|
+
[self fireEvent:@""
|
1714
|
+
event:@"on."
|
1715
|
+
@"rewa"
|
1716
|
+
@"rded"
|
1717
|
+
@".dis"
|
1718
|
+
@"miss"
|
1719
|
+
@"ed"
|
1720
|
+
withData:nil];
|
1721
|
+
if (isAdSkip != 2) {
|
1722
|
+
[self fireEvent:@""
|
1723
|
+
event:@"on"
|
1724
|
+
@".r"
|
1725
|
+
@"ew"
|
1726
|
+
@"ar"
|
1727
|
+
@"de"
|
1728
|
+
@"d."
|
1729
|
+
@"ad"
|
1730
|
+
@".s"
|
1731
|
+
@"ki"
|
1732
|
+
@"p"
|
1733
|
+
withData:nil];
|
1734
|
+
}
|
1735
|
+
/* NSLog(@"Ad did "
|
1736
|
+
@"dismiss "
|
1737
|
+
@"full screen "
|
1738
|
+
@"content "
|
1739
|
+
@"rewarded."); */
|
1740
|
+
} else if (adFormat == 4) {
|
1741
|
+
if (isAdSkip != 2) {
|
1742
|
+
[self fireEvent:@""
|
1743
|
+
event:@"on"
|
1744
|
+
@".r"
|
1745
|
+
@"ew"
|
1746
|
+
@"ar"
|
1747
|
+
@"de"
|
1748
|
+
@"dI"
|
1749
|
+
@"nt"
|
1750
|
+
@".a"
|
1751
|
+
@"d."
|
1752
|
+
@"sk"
|
1753
|
+
@"ip"
|
1754
|
+
withData:nil];
|
1713
1755
|
}
|
1756
|
+
[self fireEvent:@""
|
1757
|
+
event:@"on."
|
1758
|
+
@"rewa"
|
1759
|
+
@"rded"
|
1760
|
+
@"Int."
|
1761
|
+
@"dism"
|
1762
|
+
@"isse"
|
1763
|
+
@"d"
|
1764
|
+
withData:nil];
|
1765
|
+
/* NSLog(@"Ad did "
|
1766
|
+
@"dismiss "
|
1767
|
+
@"full screen "
|
1768
|
+
@"content "
|
1769
|
+
@"interstitial"
|
1770
|
+
@" rewarded."); */
|
1771
|
+
}
|
1714
1772
|
}
|
1715
1773
|
#pragma mark Cleanup
|
1716
|
-
- (void)dealloc
|
1717
|
-
|
1718
|
-
|
1719
|
-
|
1720
|
-
|
1721
|
-
|
1722
|
-
|
1723
|
-
|
1724
|
-
|
1725
|
-
|
1726
|
-
= nil;
|
1727
|
-
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIDeviceOrientationDidChangeNotification object:nil];
|
1774
|
+
- (void)dealloc {
|
1775
|
+
self.appOpenAd = nil;
|
1776
|
+
self.bannerView = nil;
|
1777
|
+
self.interstitial = nil;
|
1778
|
+
self.rewardedAd = nil;
|
1779
|
+
self.rewardedInterstitialAd = nil;
|
1780
|
+
[[NSNotificationCenter defaultCenter]
|
1781
|
+
removeObserver:self
|
1782
|
+
name:UIDeviceOrientationDidChangeNotification
|
1783
|
+
object:nil];
|
1728
1784
|
}
|
1729
1785
|
@end
|
1730
|
-
|