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.
@@ -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; // Deprecated
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
- return UMPConsentInformation.sharedInstance.canRequestAds;
38
+ return UMPConsentInformation.sharedInstance.canRequestAds;
39
39
  }
40
40
  - (void)setUsingAdManagerRequest:(BOOL)value {
41
- isUsingAdManagerRequest = value;
41
+ isUsingAdManagerRequest = value;
42
42
  }
43
43
  - (void)ResponseInfo:(BOOL)value {
44
- ResponseInfo = value;
44
+ ResponseInfo = value;
45
45
  }
46
46
  - (void)isDebugGeography:(BOOL)value {
47
- isDebugGeography = value;
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
- CDVPluginResult *pluginResult;
144
- NSString *callbackId = command.callbackId;
145
- if (@available(iOS 14, *)) {
146
- dispatch_async(dispatch_get_main_queue(), ^{
147
- [ATTrackingManager
148
- requestTrackingAuthorizationWithCompletionHandler:^(
149
- ATTrackingManagerAuthorizationStatus status) {
150
- if (status == ATTrackingManagerAuthorizationStatusDenied) {
151
- idfaStatus = ATTrackingManagerAuthorizationStatusDenied;
152
- } else if (status ==
153
- ATTrackingManagerAuthorizationStatusAuthorized) {
154
- idfaStatus = ATTrackingManagerAuthorizationStatusAuthorized;
155
- } else if (status ==
156
- ATTrackingManagerAuthorizationStatusRestricted) {
157
- idfaStatus = ATTrackingManagerAuthorizationStatusRestricted;
158
- } else if (status ==
159
- ATTrackingManagerAuthorizationStatusNotDetermined) {
160
- idfaStatus =
161
- ATTrackingManagerAuthorizationStatusNotDetermined;
162
- }
163
- }];
164
- });
165
- [self fireEvent:@""
166
- event:@"on."
167
- @"getI"
168
- @"DFA."
169
- @"stat"
170
- @"us"
171
- withData:nil];
172
- pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK
173
- messageAsInt:idfaStatus];
174
- } else {
175
- [self fireEvent:@""
176
- event:@"on."
177
- @"getI"
178
- @"DFA."
179
- @"erro"
180
- @"r"
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
- static dispatch_once_t onceToken;
201
- dispatch_once(&onceToken, ^{
202
- // Initialize the Google Mobile Ads SDK.
203
- GADMobileAds *ads = [GADMobileAds sharedInstance];
204
- [ads startWithCompletionHandler:^(GADInitializationStatus *status) {
205
-
206
- NSDictionary *adapterStatuses = [status adapterStatusesByClassName];
207
- NSMutableArray *adaptersArray = [NSMutableArray array];
208
-
209
- for (NSString *adapter in adapterStatuses) {
210
- GADAdapterStatus *adapterStatus = adapterStatuses[adapter];
211
- NSLog(@"Adapter Name: %@, Description: %@, Latency: %f", adapter, adapterStatus.description, adapterStatus.latency);
212
-
213
- NSDictionary *adapterInfo = @{
214
- @"name": adapter
215
- };
216
-
217
- [adaptersArray addObject:adapterInfo];
218
- }
219
-
220
- NSString *sdkVersion = GADGetStringFromVersionNumber(GADMobileAds.sharedInstance.versionNumber);
221
- int Consent_Status = (int)UMPConsentInformation.sharedInstance.consentStatus;
222
-
223
- NSMutableDictionary *result = [[NSMutableDictionary alloc] init];
224
- NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
225
- NSNumber *CmpSdkID = [prefs valueForKey:@"IABTCF_CmpSdkID"];
226
- NSString *gdprApplies = [prefs stringForKey:@"IABTCF_gdprApplies"];
227
- NSString *PurposeConsents = [prefs stringForKey:@"IABTCF_PurposeConsents"];
228
- NSString *TCString = [prefs stringForKey:@"IABTCF_TCString"];
229
- NSString *additionalConsent = [prefs stringForKey:@"IABTCF_AddtlConsent"];
230
-
231
- result[@"version"] = sdkVersion;
232
- result[@"consentStatus"] = @(Consent_Status);
233
- result[@"adapter"] = adaptersArray;
234
- result[@"CmpSdkID"] = CmpSdkID;
235
- result[@"gdprApplies"] = gdprApplies;
236
- result[@"PurposeConsents"] = PurposeConsents;
237
- result[@"TCString"] = TCString;
238
- result[@"additionalConsent"] = additionalConsent;
239
-
240
- // NSLog(@"Result dictionary: %@", result);consentStatus
241
-
242
- NSError *error;
243
- NSData *jsonData = [NSJSONSerialization dataWithJSONObject:result options:0 error:&error];
244
-
245
- if (!jsonData) {
246
- NSLog(@"Error converting result to JSON: %@", error.localizedDescription);
247
- } else {
248
- NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
249
-
250
- // NSLog(@"JSON String: %@", jsonString);
251
-
252
- [self fireEvent:@"" event:@"on.sdkInitialization" withData:jsonString];
253
- }
254
-
255
- [prefs synchronize];
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
- NSString *deviceId = [self __getAdMobDeviceId];
267
- UMPRequestParameters *parameters = [[UMPRequestParameters alloc] init];
268
-
269
- if (isDebugGeography) {
270
- UMPDebugSettings *debugSettings = [[UMPDebugSettings alloc] init];
271
- debugSettings.geography = UMPDebugGeographyEEA;
272
- debugSettings.testDeviceIdentifiers = @[ deviceId ];
273
- parameters.debugSettings = debugSettings;
274
- }
275
-
276
- parameters.tagForUnderAgeOfConsent = UnderAgeOfConsent;
277
-
278
- // [UMPConsentInformation.sharedInstance reset];
279
-
280
- dispatch_async(dispatch_get_main_queue(), ^{
281
- [UMPConsentInformation.sharedInstance
282
- requestConsentInfoUpdateWithParameters:parameters
283
- completionHandler:^(NSError *_Nullable requestConsentError) {
284
- if (requestConsentError != nil) {
285
- // NSLog(@"Errors in updating consent information: %@", requestConsentError);
286
- CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:requestConsentError.description];
287
- [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
288
- return;
289
- }
290
-
291
- // NSLog(@"Successful update of consent info. Continue to load and present consent form.");
292
-
293
- [UMPConsentForm loadAndPresentIfRequiredFromViewController:self.viewController
294
- completionHandler:^(NSError *loadAndPresentError) {
295
- if (loadAndPresentError != nil) {
296
- // NSLog(@"Error loading and presenting consent form: %@", loadAndPresentError);
297
- CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:loadAndPresentError.description];
298
- [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
299
- } else {
300
- // NSLog(@"Consent form successfully loaded");
301
- [UMPConsentForm presentPrivacyOptionsFormFromViewController:self.viewController completionHandler:^(NSError * _Nullable formError) {
302
- if (formError) {
303
- // NSLog(@"Error when displaying the form: %@", formError);
304
- } else {
305
- // NSLog(@"The privacy options form is successfully displayed.");
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
- NSString *deviceId = [self __getAdMobDeviceId];
320
- UMPRequestParameters *parameters = [[UMPRequestParameters alloc] init];
321
-
322
- if (isDebugGeography) {
323
- UMPDebugSettings *debugSettings = [[UMPDebugSettings alloc] init];
324
- parameters.debugSettings = debugSettings;
325
- debugSettings.geography = UMPDebugGeographyEEA;
326
- debugSettings.testDeviceIdentifiers = @[ deviceId ];
327
-
328
- // NSLog(@"[showPrivacyOptionsForm] Using EEA debug geography for consent.");
329
- }
330
-
331
- parameters.tagForUnderAgeOfConsent = UnderAgeOfConsent;
332
-
333
- dispatch_async(dispatch_get_main_queue(), ^{
334
- [UMPConsentInformation.sharedInstance
335
- requestConsentInfoUpdateWithParameters:parameters
336
- completionHandler:^(NSError *_Nullable requestConsentError) {
337
- if (requestConsentError != nil) {
338
- // NSLog(@"[showPrivacyOptionsForm] Error in updating consent info: %@", requestConsentError);
339
- CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:requestConsentError.description];
340
- [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
341
- return;
342
- }
343
-
344
- // NSLog(@"[showPrivacyOptionsForm] Successful update of consent info. Continue to load and present consent form.");
345
-
346
- [UMPConsentForm loadAndPresentIfRequiredFromViewController:self.viewController
347
- completionHandler:^(NSError *loadAndPresentError) {
348
- if (loadAndPresentError) {
349
- // NSLog(@"[showPrivacyOptionsForm] Error loading and presenting consent form: %@", loadAndPresentError);
350
- CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:loadAndPresentError.description];
351
- [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
352
- } else {
353
- /// NSLog(@"[showPrivacyOptionsForm] Consent form successfully displayed.");
354
- }
355
- }];
356
-
357
-
358
- if ([self isPrivacyOptionsRequired]) {
359
- // NSLog(@"[isPrivacyOptionsRequired] Privacy options required.");
360
- [self privacyOptionsFormShow:command];
361
- } else {
362
- // NSLog(@"[isPrivacyOptionsRequired] Privacy option form not required.");
363
- CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:@"The privacy option form is not required."];
364
- [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
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
- [self.commandDelegate runInBackground:^{
373
- dispatch_async(dispatch_get_main_queue(), ^{
374
- [UMPConsentForm presentPrivacyOptionsFormFromViewController:self.viewController
375
- completionHandler:^(NSError *_Nullable formError) {
376
- if (formError) {
377
- // NSLog(@"[privacyOptionsFormShow] Error displaying the privacy options form: %@", formError);
378
- CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:formError.description];
379
- [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
380
- } else {
381
- // NSLog(@"[privacyOptionsFormShow] The privacy options form is successfully displayed.");
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
- UMPPrivacyOptionsRequirementStatus status = UMPConsentInformation.sharedInstance.privacyOptionsRequirementStatus;
391
- // NSLog(@"[isPrivacyOptionsRequired] Privacy option status: %ld", (long)status);
392
- return status == UMPPrivacyOptionsRequirementStatusRequired;
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
- [self.commandDelegate runInBackground:^{
398
- Consent_Status = (int)UMPConsentInformation.sharedInstance.consentStatus;
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
- - (void)targeting:(CDVInvokedUrlCommand *)command {
520
- CDVPluginResult *pluginResult;
521
- NSString *callbackId = command.callbackId;
522
- NSDictionary *options = [command.arguments objectAtIndex:0];
523
- BOOL childDirectedTreatment = [[options valueForKey:@"childDirectedTreatment"] boolValue];
524
- BOOL underAgeOfConsent = [[options valueForKey:@"underAgeOfConsent"] boolValue];
525
- NSString *contentRating = [options valueForKey:@"contentRating"];
526
- @try {
527
- GADRequestConfiguration *requestConfiguration = GADMobileAds.sharedInstance.requestConfiguration;
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
- - (void)pluginInitialize {
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:@"IABTCF"
569
- @"_CmpSd"
570
- @"kID"];
571
- NSString *gdprApplies = [prefs stringForKey:@"IABTCF"
572
- @"_gdprA"
573
- @"pplie"
574
- @"s"];
575
- NSString *PurposeConsents = [prefs stringForKey:@"IABTCF"
576
- @"_Purpo"
577
- @"seCons"
578
- @"ents"];
579
- NSString *TCString = [prefs stringForKey:@"IABTCF"
580
- @"_TCStr"
581
- @"ing"];
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
- @"gdprApplies"] = gdprApplies;
603
+ @"gdprAppli"
604
+ @"es"] = gdprApplies;
586
605
  result[@"IABTCF_"
587
- @"PurposeCons"
588
- @"ents"] = PurposeConsents;
606
+ @"PurposeCo"
607
+ @"nsents"] = PurposeConsents;
589
608
  result[@"IABTCF_"
590
609
  @"TCString"] = TCString;
591
- // NSLog(@"%@",
592
- // [[NSUserDefaults
593
- // standardUserDefaults]
594
- // dictionaryRepresentation]);
595
- [prefs synchronize];
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
- - (void)orientationDidChange:(NSNotification *)notification {
607
- // NSLog(@"Orientation changed");
608
- [self fireEvent:@"" event:@"on.screen.rotated" withData:nil];
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
- self.bannerView.translatesAutoresizingMaskIntoConstraints = NO;
659
-
660
- // Tambahkan constraint berdasarkan posisi
661
- if ([Position isEqualToString:@"bottom-center"]) {
662
- [self.viewController.view addConstraints:@[
663
- [NSLayoutConstraint constraintWithItem:self.bannerView
664
- attribute:NSLayoutAttributeBottom
665
- relatedBy:NSLayoutRelationEqual
666
- toItem:self.viewController.view.safeAreaLayoutGuide
667
- attribute:NSLayoutAttributeBottom
668
- multiplier:1
669
- constant:0],
670
- [NSLayoutConstraint constraintWithItem:self.bannerView
671
- attribute:NSLayoutAttributeCenterX
672
- relatedBy:NSLayoutRelationEqual
673
- toItem:self.viewController.view
674
- attribute:NSLayoutAttributeCenterX
675
- multiplier:1
676
- constant:0]
677
- ]];
678
- } else if ([Position isEqualToString:@"top-center"]) {
679
- [self.viewController.view addConstraints:@[
680
- [NSLayoutConstraint constraintWithItem:self.bannerView
681
- attribute:NSLayoutAttributeTop
682
- relatedBy:NSLayoutRelationEqual
683
- toItem:self.viewController.view.safeAreaLayoutGuide
684
- attribute:NSLayoutAttributeTop
685
- multiplier:1
686
- constant:0],
687
- [NSLayoutConstraint constraintWithItem:self.bannerView
688
- attribute:NSLayoutAttributeCenterX
689
- relatedBy:NSLayoutRelationEqual
690
- toItem:self.viewController.view
691
- attribute:NSLayoutAttributeCenterX
692
- multiplier:1
693
- constant:0]
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
- - (void)loadBannerAd:(CDVInvokedUrlCommand *)command {
706
- CDVPluginResult *pluginResult;
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
- - (GADAdSize)__AdSizeFromString:(NSString *)size {
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
- - (void)showBannerAd:(CDVInvokedUrlCommand *)command {
812
- CDVPluginResult *pluginResult;
813
- NSString *callbackId = command.callbackId;
814
- if (self.bannerView) {
815
- self.bannerView.hidden = NO;
816
- [self addBannerViewToView:command];
817
- pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
818
- } else {
819
- [self fireEvent:@""
820
- event:@"on."
821
- @"bann"
822
- @"er."
823
- @"fail"
824
- @"ed."
825
- @"show"
826
- withData:nil];
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
- bannerView.translatesAutoresizingMaskIntoConstraints = NO;
838
- [self.viewController.view addSubview:bannerView];
839
- if ([Position isEqualToString:@"bottom-center"]) {
840
- [self.viewController.view addConstraints:@[
841
- [NSLayoutConstraint
842
- constraintWithItem:bannerView
843
- attribute:NSLayoutAttributeBottom
844
- relatedBy:NSLayoutRelationEqual
845
- toItem:self.viewController.view.safeAreaLayoutGuide
846
- attribute:NSLayoutAttributeBottom
847
- multiplier:1
848
- constant:0],
849
- [NSLayoutConstraint constraintWithItem:bannerView
850
- attribute:NSLayoutAttributeCenterX
851
- relatedBy:NSLayoutRelationEqual
852
- toItem:self.viewController.view
853
- attribute:NSLayoutAttributeCenterX
854
- multiplier:1
855
- constant:0]
856
- ]];
857
- } else if ([Position isEqualToString:@"top-center"]) {
858
-
859
- [self.viewController.view addConstraints:@[
860
- [NSLayoutConstraint
861
- constraintWithItem:bannerView
862
- attribute:NSLayoutAttributeTop
863
- relatedBy:NSLayoutRelationEqual
864
- toItem:self.viewController.view.safeAreaLayoutGuide
865
- attribute:NSLayoutAttributeTop
866
- multiplier:1
867
- constant:0],
868
- [NSLayoutConstraint constraintWithItem:bannerView
869
- attribute:NSLayoutAttributeCenterX
870
- relatedBy:NSLayoutRelationEqual
871
- toItem:self.viewController.view
872
- attribute:NSLayoutAttributeCenterX
873
- multiplier:1
874
- constant:0]
875
- ]];
876
-
877
- } else
878
- {
879
- [self.viewController.view addConstraints:@[
880
- [NSLayoutConstraint
881
- constraintWithItem:bannerView
882
- attribute:NSLayoutAttributeBottom
883
- relatedBy:NSLayoutRelationEqual
884
- toItem:self.viewController.view.safeAreaLayoutGuide
885
- attribute:NSLayoutAttributeTop
886
- multiplier:1
887
- constant:0],
888
- [NSLayoutConstraint constraintWithItem:bannerView
889
- attribute:NSLayoutAttributeCenterX
890
- relatedBy:NSLayoutRelationEqual
891
- toItem:self.viewController.view
892
- attribute:NSLayoutAttributeCenterX
893
- multiplier:1
894
- constant:0]
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
- CDVPluginResult *pluginResult;
900
- NSString *callbackId = command.callbackId;
901
- if (self.bannerView) {
902
- dispatch_async(dispatch_get_main_queue(), ^{
903
- self.bannerView.hidden = YES;
904
- [self fireEvent:@"" event:@"on.banner.hide" withData:nil];
905
- });
906
- pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
907
- } else {
908
- pluginResult =
909
- [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
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
- CDVPluginResult *pluginResult;
915
- NSString *callbackId = command.callbackId;
916
- if (self.bannerView) {
917
- dispatch_async(dispatch_get_main_queue(), ^{
918
- self.bannerView.hidden = YES;
919
- [self.bannerView removeFromSuperview];
920
- self.bannerView = nil;
921
- [self fireEvent:@"" event:@"on.banner.remove" withData:nil];
922
- });
923
- pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
924
- } else {
925
- pluginResult =
926
- [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
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
- CDVPluginResult *pluginResult;
932
- NSString *callbackId = command.callbackId;
933
- NSDictionary *options = [command.arguments objectAtIndex:0];
934
- NSString *adUnitId = [options valueForKey:@"adUnitId"];
935
- BOOL autoShow = [[options valueForKey:@"autoShow"] boolValue];
936
- auto_Show = autoShow;
937
- adFormat = 1;
938
- self.appOpenAd = nil;
939
- if (adFormat == 1) {
940
- dispatch_async(dispatch_get_main_queue(), ^{
941
- GADRequest *request = [GADRequest request];
942
- GADExtras *extras = [[GADExtras alloc] init];
943
- // extras.additionalParameters = @{@"npa" : Npa}; // Deprecated
944
- [request registerAdNetworkExtras:extras];
945
- [GADAppOpenAd
946
- loadWithAdUnitID:adUnitId
947
- request:request
948
- completionHandler:^(GADAppOpenAd *ad, NSError *error) {
949
- if (error) {
950
- [self fireEvent:@""
951
- event:@"on.appOpenAd.failed.loaded"
952
- withData:nil];
953
- NSLog(@"Fa"
954
- @"il"
955
- @"ed"
956
- @" t"
957
- @"o "
958
- @"lo"
959
- @"ad"
960
- @" A"
961
- @"pp"
962
- @" O"
963
- @"pe"
964
- @"n "
965
- @"Ad"
966
- @" a"
967
- @"d "
968
- @"wi"
969
- @"th"
970
- @" e"
971
- @"rr"
972
- @"or"
973
- @": "
974
- @"%"
975
- @"@",
976
- [error localizedDescription]);
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
- CDVPluginResult *pluginResult;
1003
- NSString *callbackId = command.callbackId;
1004
- if (self.appOpenAd &&
1005
- [self.appOpenAd canPresentFromRootViewController:self.viewController
1006
- error:nil]) {
1007
- [self.appOpenAd presentFromRootViewController:self.viewController];
1008
- pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
1009
- } else {
1010
- pluginResult =
1011
- [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
1012
- [self fireEvent:@""
1013
- event:@"on."
1014
- @"appO"
1015
- @"penA"
1016
- @"d."
1017
- @"fail"
1018
- @"ed."
1019
- @"show"
1020
- withData:nil];
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
- CDVPluginResult *pluginResult;
1026
- NSString *callbackId = command.callbackId;
1027
- NSDictionary *options = [command.arguments objectAtIndex:0];
1028
- NSString *adUnitId = [options valueForKey:@"adUnitId"];
1029
- BOOL autoShow = [[options valueForKey:@"autoShow"] boolValue];
1030
- auto_Show = autoShow;
1031
- adFormat = 2;
1032
- if (adFormat == 2) {
1033
- dispatch_async(dispatch_get_main_queue(), ^{
1034
- GADRequest *request = [GADRequest request];
1035
- [GADInterstitialAd
1036
- loadWithAdUnitID:adUnitId
1037
- request:request
1038
- completionHandler:^(GADInterstitialAd *ad, NSError *error) {
1039
- if (error) {
1040
- NSLog(@"Fa"
1041
- @"il"
1042
- @"ed"
1043
- @" t"
1044
- @"o "
1045
- @"lo"
1046
- @"ad"
1047
- @" i"
1048
- @"nt"
1049
- @"er"
1050
- @"st"
1051
- @"it"
1052
- @"ia"
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.loaded"
1154
+ event:@"on.interstitial.failed.show"
1069
1155
  withData:nil];
1070
- if (auto_Show) {
1071
- if (self.interstitial &&
1072
- [self.interstitial
1073
- canPresentFromRootViewController:self.viewController
1074
- error:nil]) {
1075
- [self.interstitial
1076
- presentFromRootViewController:self.viewController];
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
- CDVPluginResult *pluginResult;
1091
- NSString *callbackId = command.callbackId;
1092
- if (self.interstitial &&
1093
- [self.interstitial canPresentFromRootViewController:self.viewController
1094
- error:nil]) {
1095
- [self.interstitial presentFromRootViewController:self.viewController];
1096
- pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
1097
- } else {
1098
- pluginResult =
1099
- [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
1100
- [self fireEvent:@""
1101
- event:@"on."
1102
- @"inte"
1103
- @"rsti"
1104
- @"tial"
1105
- @".fai"
1106
- @"led."
1107
- @"show"
1108
- withData:nil];
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
- CDVPluginResult *pluginResult;
1114
- NSString *callbackId = command.callbackId;
1115
-
1116
- NSDictionary *options = [command.arguments objectAtIndex:0];
1117
- NSString *adUnitId = [options valueForKey:@"adUnitId"];
1118
- BOOL autoShow = [[options valueForKey:@"autoShow"] boolValue];
1119
-
1120
- auto_Show = autoShow;
1121
- adFormat = 4;
1122
- if (adFormat == 4) {
1123
- dispatch_async(dispatch_get_main_queue(), ^{
1124
- GADRequest *request = [GADRequest request];
1125
- [GADRewardedInterstitialAd
1126
- loadWithAdUnitID:adUnitId
1127
- request:request
1128
- completionHandler:^(GADRewardedInterstitialAd *ad,
1129
- NSError *error) {
1130
- if (error) {
1131
- NSLog(@"Rewarded ad failed to load with error: %@",
1132
- [error localizedDescription]);
1133
- return;
1134
- }
1135
- self.rewardedInterstitialAd = ad;
1136
- isAdSkip = 1;
1137
- NSLog(@"Rewarded ad loaded.");
1138
- self.rewardedInterstitialAd.fullScreenContentDelegate = self;
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.loaded"
1237
+ event:@"on.rewardedInt.failed.show"
1141
1238
  withData:nil];
1142
- if (auto_Show) {
1143
- if (self.rewardedInterstitialAd &&
1144
- [self.rewardedInterstitialAd
1145
- canPresentFromRootViewController:self.viewController
1146
- error:nil]) {
1147
- [self.rewardedInterstitialAd
1148
- presentFromRootViewController:self.viewController
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
- CDVPluginResult *pluginResult;
1179
- NSString *callbackId = command.callbackId;
1180
- if (self.rewardedInterstitialAd &&
1181
- [self.rewardedInterstitialAd
1182
- canPresentFromRootViewController:self.viewController
1183
- error:nil]) {
1184
- [self.rewardedInterstitialAd
1185
- presentFromRootViewController:self.viewController
1186
- userDidEarnRewardHandler:^{
1187
- GADAdReward *reward = self.rewardedInterstitialAd.adReward;
1188
- [self fireEvent:@""
1189
- event:@"on.rewardedInt.userEarnedReward"
1190
- withData:nil];
1191
- isAdSkip = 2;
1192
- NSString *rewardMessage = [NSString
1193
- stringWithFormat:@"Reward received with "
1194
- @"currency %@ , amount %ld",
1195
- reward.type, [reward.amount longValue]];
1196
- NSLog(@"%"
1197
- @"@",
1198
- rewardMessage);
1199
- }];
1200
- pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
1201
- } else {
1202
- pluginResult =
1203
- [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
1204
- [self fireEvent:@""
1205
- event:@"on."
1206
- @"rewa"
1207
- @"rded"
1208
- @"Int."
1209
- @"fail"
1210
- @"ed."
1211
- @"show"
1212
- withData:nil];
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
- CDVPluginResult *pluginResult;
1218
- NSString *callbackId = command.callbackId;
1219
- NSDictionary *options = [command.arguments objectAtIndex:0];
1220
- NSString *adUnitId = [options valueForKey:@"adUnitId"];
1221
- BOOL autoShow = [[options valueForKey:@"autoShow"] boolValue];
1222
- auto_Show = autoShow;
1223
- adFormat = 3;
1224
- if (adFormat == 3) {
1225
- dispatch_async(dispatch_get_main_queue(), ^{
1226
- GADRequest *request = [GADRequest request];
1227
- [GADRewardedAd
1228
- loadWithAdUnitID:adUnitId
1229
- request:request
1230
- completionHandler:^(GADRewardedAd *ad, NSError *error) {
1231
- if (error) {
1232
- NSLog(@"Rewarded ad failed to load with error: %@",
1233
- [error localizedDescription]);
1234
- return;
1235
- }
1236
- self.rewardedAd = ad;
1237
- NSLog(@"Rewarded ad loaded.");
1238
- isAdSkip = 0;
1239
- self.rewardedAd.fullScreenContentDelegate = self;
1240
- [self fireEvent:@"" event:@"on.rewarded.loaded" withData:nil];
1241
- if (auto_Show) {
1242
- if (self.rewardedAd &&
1243
- [self.rewardedAd
1244
- canPresentFromRootViewController:self.viewController
1245
- error:nil]) {
1246
- [self.rewardedAd
1247
- presentFromRootViewController:self.viewController
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
- GADAdReward *reward =
1250
- self.rewardedAd.adReward;
1251
- [self fireEvent:@""
1252
- event:@"on.reward.userEarnedReward"
1253
- withData:nil];
1254
- isAdSkip = 2;
1255
- NSString *rewardMessage = [NSString
1256
- stringWithFormat:
1257
- @"Reward received with currency "
1258
- @"%@ , amount %lf",
1259
- reward.type,
1260
- [reward.amount doubleValue]];
1261
- NSLog(@"%@", rewardMessage);
1262
- }];
1263
- } else {
1264
- [self fireEvent:@""
1265
- event:@"on.rewarded.failed.show"
1266
- withData:nil];
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
- CDVPluginResult *pluginResult;
1277
- NSString *callbackId = command.callbackId;
1278
- if (self.rewardedAd &&
1279
- [self.rewardedAd canPresentFromRootViewController:self.viewController
1280
- error:nil]) {
1281
- [self.rewardedAd
1282
- presentFromRootViewController:self.viewController
1283
- userDidEarnRewardHandler:^{
1284
- GADAdReward *reward = self.rewardedAd.adReward;
1285
- [self fireEvent:@""
1286
- event:@"on.reward.userEarnedReward"
1287
- withData:nil];
1288
- isAdSkip = 2;
1289
- NSString *rewardMessage = [NSString
1290
- stringWithFormat:
1291
- @"Reward received with currency %@ , amount %lf",
1292
- reward.type, [reward.amount doubleValue]];
1293
- NSLog(@"%"
1294
- @"@",
1295
- rewardMessage);
1296
- }];
1297
- pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
1298
- } else {
1299
- pluginResult =
1300
- [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
1301
- [self fireEvent:@""
1302
- event:@"on."
1303
- @"rewa"
1304
- @"rded"
1305
- @".fai"
1306
- @"led."
1307
- @"show"
1308
- withData:nil];
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
- NSString *js;
1316
- if (obj && [obj isEqualToString:@"windo"
1317
- @"w"]) {
1318
- js = [NSString stringWithFormat:@"var "
1319
- @"evt="
1320
- @"document"
1321
- @".createE"
1322
- @"vent("
1323
- @"\"UIEven"
1324
- @"ts\");"
1325
- @"evt."
1326
- @"initUIEv"
1327
- @"ent("
1328
- @"\"%@\","
1329
- @"true,"
1330
- @"false,"
1331
- @"window,"
1332
- @"0);"
1333
- @"window."
1334
- @"dispatch"
1335
- @"Event("
1336
- @"evt);",
1337
- eventName];
1338
- } else if (jsonStr && [jsonStr length] > 0) {
1339
- js = [NSString stringWithFormat:@"javascri"
1340
- @"pt:"
1341
- @"cordova."
1342
- @"fireDocu"
1343
- @"mentEven"
1344
- @"t('%@',%"
1345
- @"@);",
1346
- eventName, jsonStr];
1347
- } else {
1348
- js = [NSString stringWithFormat:@"javascri"
1349
- @"pt:"
1350
- @"cordova."
1351
- @"fireDocu"
1352
- @"mentEven"
1353
- @"t('%@')"
1354
- @";",
1355
- eventName];
1356
- }
1357
- [self.commandDelegate evalJs:js];
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
- NSUUID *adid = [[ASIdentifierManager sharedManager] advertisingIdentifier];
1362
- return [self __md5:adid.UUIDString];
1427
+ NSUUID *adid = [[ASIdentifierManager sharedManager] advertisingIdentifier];
1428
+ return [self __sha256:adid.UUIDString];
1363
1429
  }
1364
1430
 
1365
- - (NSString *)__md5:(NSString *)string {
1366
- CC_MD5_CTX
1367
- md5Context;
1368
- CC_MD5_Init(&md5Context);
1369
- NSData *data = [string dataUsingEncoding:NSUTF8StringEncoding];
1370
- CC_MD5_Update(&md5Context, [data bytes], (CC_LONG)[data length]);
1371
- unsigned char digest[CC_MD5_DIGEST_LENGTH];
1372
- CC_MD5_Final(digest, &md5Context);
1373
-
1374
- NSMutableString *hexString =
1375
- [NSMutableString stringWithCapacity:(CC_MD5_DIGEST_LENGTH * 2)];
1376
- for (int i = 0; i < CC_MD5_DIGEST_LENGTH; i++) {
1377
- [hexString appendFormat:@"%02x", digest[i]];
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
- NSString *collapsibleStatus = bannerView.isCollapsible ? @"collapsible" : @"not collapsible";
1387
- NSDictionary *eventData = @{ @"collapsible": collapsibleStatus };
1388
- NSError *error;
1389
- NSData *jsonData = [NSJSONSerialization dataWithJSONObject:eventData options:0 error:&error];
1390
-
1391
- if (!jsonData) {
1392
- NSLog(@"Failed to serialize event data: %@", error);
1393
- } else {
1394
- NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
1395
- [self fireEvent:@"" event:@"on.is.collapsible" withData:jsonString];
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
- @"banner"
1401
- @".load"
1481
+ @"bann"
1482
+ @"er."
1483
+ @"fail"
1484
+ @"ed."
1485
+ @"show"
1402
1486
  withData:nil];
1403
- NSLog(@"bannerViewDidR"
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
- [self fireEvent:@""
1424
- event:@"on."
1425
- @"banner"
1426
- @".faile"
1427
- @"d.load"
1428
- withData:nil];
1429
- NSLog(@"bannerView:"
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
- @"banner"
1439
- @".impre"
1440
- @"ssion"
1539
+ @"appO"
1540
+ @"penA"
1541
+ @"d."
1542
+ @"show"
1441
1543
  withData:nil];
1442
- NSLog(@"bannerViewD"
1443
- @"idRecordImp"
1444
- @"ression");
1445
- }
1446
- - (void)bannerViewWillPresentScreen:(GADBannerView *)bannerView {
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
- @"banner"
1450
- @".open"
1553
+ @"inte"
1554
+ @"rsti"
1555
+ @"tial"
1556
+ @".sho"
1557
+ @"w"
1451
1558
  withData:nil];
1452
- NSLog(@"bannerViewW"
1453
- @"illPresentS"
1454
- @"creen");
1455
- }
1456
- - (void)bannerViewWillDismissScreen:(GADBannerView *)bannerView {
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
- @"banner"
1460
- @".close"
1573
+ @"rewa"
1574
+ @"rded"
1575
+ @".sho"
1576
+ @"w"
1461
1577
  withData:nil];
1462
- NSLog(@"bannerViewW"
1463
- @"illDismissS"
1464
- @"creen");
1465
- }
1466
- - (void)bannerViewDidDismissScreen:(GADBannerView *)bannerView {
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
- @"banner"
1470
- @".did."
1471
- @"dismis"
1472
- @"s"
1588
+ @"rewa"
1589
+ @"rded"
1590
+ @"Int."
1591
+ @"show"
1592
+ @"ed"
1473
1593
  withData:nil];
1474
- NSLog(@"bannerViewDidD"
1475
- @"ismissScreen");
1476
- }
1477
- #pragma GADFullScreeContentDelegate implementation
1478
- - (void)adWillPresentFullScreenContent:(id)ad {
1479
- if (adFormat == 1) {
1480
- [self fireEvent:@""
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
- if (adFormat == 1) {
1546
- [self fireEvent:@""
1547
- event:@"on."
1548
- @"appO"
1549
- @"penA"
1550
- @"d."
1551
- @"fail"
1552
- @"ed."
1553
- @"load"
1554
- @"ed"
1555
- withData:nil];
1556
- NSLog(@"Ad failed "
1557
- @"to present "
1558
- @"full screen "
1559
- @"content "
1560
- @"with error "
1561
- @"App Open Ad "
1562
- @"%@.",
1563
- [error localizedDescription]);
1564
- } else if (adFormat == 2) {
1565
- [self fireEvent:@""
1566
- event:@"on."
1567
- @"inte"
1568
- @"rsti"
1569
- @"tial"
1570
- @".fai"
1571
- @"led."
1572
- @"load"
1573
- withData:nil];
1574
- NSLog(@"Ad failed "
1575
- @"to present "
1576
- @"full screen "
1577
- @"content "
1578
- @"with error "
1579
- @"interstitial"
1580
- @" %@.",
1581
- [error localizedDescription]);
1582
- } else if (adFormat == 3) {
1583
- [self fireEvent:@""
1584
- event:@"on."
1585
- @"rewa"
1586
- @"rded"
1587
- @".fai"
1588
- @"led."
1589
- @"load"
1590
- withData:nil];
1591
- NSLog(@"Ad failed "
1592
- @"to present "
1593
- @"full screen "
1594
- @"content "
1595
- @"with error "
1596
- @"rewarded "
1597
- @"%@.",
1598
- [error localizedDescription]);
1599
- } else if (adFormat == 4) {
1600
- [self fireEvent:@""
1601
- event:@"on."
1602
- @"rewa"
1603
- @"rded"
1604
- @"Int."
1605
- @"fail"
1606
- @"ed."
1607
- @"load"
1608
- withData:nil];
1609
- NSLog(@"Ad failed "
1610
- @"to present "
1611
- @"full screen "
1612
- @"content "
1613
- @"with error "
1614
- @"interstitial"
1615
- @" "
1616
- @"rewarded "
1617
- @"%@.",
1618
- [error localizedDescription]);
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
- if (adFormat == 1) {
1624
- [self fireEvent:@""
1625
- event:@"on."
1626
- @"appO"
1627
- @"penA"
1628
- @"d."
1629
- @"dism"
1630
- @"isse"
1631
- @"d"
1632
- withData:nil];
1633
- NSLog(@"Ad did "
1634
- @"dismiss "
1635
- @"full screen "
1636
- @"content App "
1637
- @"Open Ad.");
1638
- } else if (adFormat == 2) {
1639
- [self fireEvent:@""
1640
- event:@"on."
1641
- @"inte"
1642
- @"rsti"
1643
- @"tial"
1644
- @".dis"
1645
- @"miss"
1646
- @"ed"
1647
- withData:nil];
1648
- NSLog(@"Ad did "
1649
- @"dismiss "
1650
- @"full screen "
1651
- @"content "
1652
- @"interstitial"
1653
- @".");
1654
- } else if (adFormat == 3) {
1655
- [self fireEvent:@""
1656
- event:@"on."
1657
- @"rewa"
1658
- @"rded"
1659
- @".dis"
1660
- @"miss"
1661
- @"ed"
1662
- withData:nil];
1663
- if (isAdSkip != 2) {
1664
- [self fireEvent:@""
1665
- event:@"on"
1666
- @".r"
1667
- @"ew"
1668
- @"ar"
1669
- @"de"
1670
- @"d."
1671
- @"ad"
1672
- @".s"
1673
- @"ki"
1674
- @"p"
1675
- withData:nil];
1676
- }
1677
- NSLog(@"Ad did "
1678
- @"dismiss "
1679
- @"full screen "
1680
- @"content "
1681
- @"rewarded.");
1682
- } else if (adFormat == 4) {
1683
- if (isAdSkip != 2) {
1684
- [self fireEvent:@""
1685
- event:@"on"
1686
- @".r"
1687
- @"ew"
1688
- @"ar"
1689
- @"de"
1690
- @"dI"
1691
- @"nt"
1692
- @".a"
1693
- @"d."
1694
- @"sk"
1695
- @"ip"
1696
- withData:nil];
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
- self.appOpenAd = nil;
1719
- self.bannerView
1720
- = nil;
1721
- self.interstitial
1722
- = nil;
1723
- self.rewardedAd
1724
- = nil;
1725
- self.rewardedInterstitialAd
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
-