emi-indo-cordova-plugin-admob 1.5.0 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/ISSUE_TEMPLATE/bug_report.md +3 -0
- package/README.md +177 -9
- package/package.json +2 -1
- package/plugin.xml +15 -37
- package/src/ios/emiAdmobPlugin.h +7 -2
- package/src/ios/emiAdmobPlugin.m +1645 -438
- package/www/emiAdmobPlugin.js +7 -4
- package/.vscode/debug/app-debug.apk +0 -0
- package/.vscode/debug/output-metadata.json +0 -21
- package/.vscode/settings.json +0 -3
package/src/ios/emiAdmobPlugin.m
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
#import "emiAdmobPlugin.h"
|
2
|
-
#import <Cordova/CDVPlugin.h>
|
3
|
-
#import <UserMessagingPlatform/UserMessagingPlatform.h>
|
4
|
-
#import <AppTrackingTransparency/AppTrackingTransparency.h>
|
5
2
|
#import <AdSupport/AdSupport.h>
|
3
|
+
#import <AppTrackingTransparency/AppTrackingTransparency.h>
|
4
|
+
#import <Cordova/CDVPlugin.h>
|
6
5
|
#import <Foundation/Foundation.h>
|
6
|
+
#import <UserMessagingPlatform/UserMessagingPlatform.h>
|
7
7
|
@implementation emiAdmobPlugin
|
8
8
|
@synthesize appOpenAd;
|
9
9
|
@synthesize bannerView;
|
@@ -14,227 +14,660 @@
|
|
14
14
|
@synthesize responseInfo;
|
15
15
|
@synthesize isPrivacyOptionsRequired;
|
16
16
|
int idfaStatus = 0;
|
17
|
-
int fromStatus = 0;
|
17
|
+
int fromStatus = 0; // Deprecated
|
18
|
+
int Consent_Status = 0;
|
18
19
|
int adFormat = 0;
|
19
|
-
int adWidth = 320;
|
20
|
+
int adWidth = 320; // Deprecated
|
20
21
|
BOOL auto_Show = NO;
|
21
|
-
NSString *Npa = @"1";
|
22
|
+
// NSString *Npa = @"1"; // Deprecated
|
22
23
|
NSString *Position = @"bottom";
|
23
|
-
|
24
|
-
|
24
|
+
NSString *bannerSaveAdUnitId = @""; // autoResize dependency = true
|
25
|
+
|
26
|
+
BOOL enableCollapsible = NO;
|
27
|
+
BOOL isAutoResize = NO;
|
28
|
+
|
25
29
|
int isAdSkip = 0;
|
26
30
|
BOOL isIAB = NO;
|
27
|
-
BOOL UnderAgeOfConsent = NO
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
NSString *PurposeConsents = [prefs stringForKey:@"IABTCF_PurposeConsents"];
|
107
|
-
NSString *TCString = [prefs stringForKey:@"IABTCF_TCString"]; result[@"IABTCF_CmpSdkID"] = CmpSdkID;
|
108
|
-
result[@"IABTCF_gdprApplies"] = gdprApplies;
|
109
|
-
result[@"IABTCF_PurposeConsents"] = PurposeConsents;
|
110
|
-
result[@"IABTCF_TCString"] = TCString; [[NSUserDefaults standardUserDefaults] synchronize]; NSLog(@"%@", [[NSUserDefaults standardUserDefaults] dictionaryRepresentation]);
|
111
|
-
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:result];
|
112
|
-
[self fireEvent:@"" event:@"on.getIabTfc" withData:nil]; } else { pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
|
113
|
-
} [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
114
|
-
}- (void)consentReset:(CDVInvokedUrlCommand*)command {
|
115
|
-
CDVPluginResult *pluginResult;
|
116
|
-
NSString *callbackId = command.callbackId;
|
117
|
-
@try {
|
118
|
-
[[UMPConsentInformation sharedInstance] reset];
|
119
|
-
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
120
|
-
}@catch (NSException *exception) {
|
121
|
-
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:exception.reason];
|
122
|
-
}
|
123
|
-
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
124
|
-
}- (void)setPublisherFirstPartyIDEnabled:(BOOL)enabled{};- (void)globalSettings:(CDVInvokedUrlCommand*)command {
|
125
|
-
CDVPluginResult *pluginResult;
|
126
|
-
NSString *callbackId = command.callbackId;
|
127
|
-
BOOL setAppMuted = [[command argumentAtIndex:0] boolValue];
|
128
|
-
float setAppVolume = [[command argumentAtIndex:1] floatValue];
|
129
|
-
BOOL publisherFirstPartyIdEnabled = [[command argumentAtIndex:3] boolValue];
|
130
|
-
NSString* npa = [command.arguments objectAtIndex:2];
|
131
|
-
BOOL enableCollapsible = [[command argumentAtIndex:3] boolValue];
|
132
|
-
BOOL responseInfo = [[command argumentAtIndex:4] boolValue];
|
133
|
-
@try {
|
134
|
-
GADMobileAds.sharedInstance.applicationVolume = setAppVolume;
|
135
|
-
GADMobileAds.sharedInstance.applicationMuted = setAppMuted;
|
136
|
-
[self setPublisherFirstPartyIDEnabled:publisherFirstPartyIdEnabled];
|
137
|
-
Npa = npa;
|
138
|
-
EnableCollapsible = enableCollapsible;
|
139
|
-
ResponseInfo = responseInfo;
|
140
|
-
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
141
|
-
}@catch (NSException *exception) {
|
142
|
-
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:exception.reason];
|
31
|
+
BOOL UnderAgeOfConsent = NO;
|
32
|
+
BOOL isPrivacyOptions = NO;
|
33
|
+
BOOL isDebugGeography = NO;
|
34
|
+
BOOL ResponseInfo = NO;
|
35
|
+
BOOL isUsingAdManagerRequest = YES;
|
36
|
+
|
37
|
+
- (BOOL)canRequestAds {
|
38
|
+
return UMPConsentInformation.sharedInstance.canRequestAds;
|
39
|
+
}
|
40
|
+
- (void)setUsingAdManagerRequest:(BOOL)value {
|
41
|
+
isUsingAdManagerRequest = value;
|
42
|
+
}
|
43
|
+
- (void)ResponseInfo:(BOOL)value {
|
44
|
+
ResponseInfo = value;
|
45
|
+
}
|
46
|
+
- (void)isDebugGeography:(BOOL)value {
|
47
|
+
isDebugGeography = value;
|
48
|
+
}
|
49
|
+
|
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."];
|
143
110
|
}
|
144
111
|
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
145
|
-
}
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
{
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
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
|
+
|
141
|
+
|
142
|
+
- (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];
|
175
184
|
}
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
185
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
186
|
+
}
|
187
|
+
|
188
|
+
- (void)getConsentRequest:(CDVInvokedUrlCommand *)command {
|
189
|
+
|
190
|
+
}
|
191
|
+
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
- (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
|
+
});
|
258
|
+
}
|
259
|
+
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
|
264
|
+
|
265
|
+
- (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;
|
180
274
|
}
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
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
|
+
});
|
312
|
+
}
|
313
|
+
|
314
|
+
|
315
|
+
|
316
|
+
|
317
|
+
|
318
|
+
- (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
|
+
});
|
368
|
+
}
|
369
|
+
|
370
|
+
|
371
|
+
- (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
|
+
}];
|
386
|
+
}
|
387
|
+
|
388
|
+
// Cek apakah opsi privasi diperlukan
|
389
|
+
- (BOOL)isPrivacyOptionsRequired {
|
390
|
+
UMPPrivacyOptionsRequirementStatus status = UMPConsentInformation.sharedInstance.privacyOptionsRequirementStatus;
|
391
|
+
// NSLog(@"[isPrivacyOptionsRequired] Privacy option status: %ld", (long)status);
|
392
|
+
return status == UMPPrivacyOptionsRequirementStatusRequired;
|
393
|
+
}
|
394
|
+
|
395
|
+
|
396
|
+
- (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;
|
201
412
|
}
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
self.
|
209
|
-
|
210
|
-
|
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];
|
211
475
|
} else {
|
212
|
-
|
213
|
-
|
476
|
+
pluginResult =
|
477
|
+
[CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
|
214
478
|
}
|
215
479
|
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
216
|
-
}
|
480
|
+
}
|
481
|
+
- (void)consentReset:(CDVInvokedUrlCommand *)command {
|
217
482
|
CDVPluginResult *pluginResult;
|
218
483
|
NSString *callbackId = command.callbackId;
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR
|
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];
|
224
490
|
}
|
225
491
|
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
226
|
-
}
|
227
|
-
|
228
|
-
|
492
|
+
}
|
493
|
+
|
494
|
+
|
495
|
+
|
496
|
+
|
497
|
+
|
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];
|
514
|
+
}
|
515
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
516
|
+
}
|
517
|
+
|
518
|
+
|
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];
|
552
|
+
}
|
553
|
+
|
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;
|
566
|
+
NSMutableDictionary *result = [[NSMutableDictionary alloc] init];
|
567
|
+
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"];
|
582
|
+
result[@"IABTCF_"
|
583
|
+
@"CmpSdkID"] = CmpSdkID;
|
584
|
+
result[@"IABTCF_"
|
585
|
+
@"gdprApplies"] = gdprApplies;
|
586
|
+
result[@"IABTCF_"
|
587
|
+
@"PurposeCons"
|
588
|
+
@"ents"] = PurposeConsents;
|
589
|
+
result[@"IABTCF_"
|
590
|
+
@"TCString"] = TCString;
|
591
|
+
// NSLog(@"%@",
|
592
|
+
// [[NSUserDefaults
|
593
|
+
// standardUserDefaults]
|
594
|
+
// dictionaryRepresentation]);
|
595
|
+
[prefs synchronize];
|
596
|
+
|
597
|
+
|
598
|
+
|
599
|
+
}
|
600
|
+
|
601
|
+
|
602
|
+
|
603
|
+
|
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
|
+
}
|
650
|
+
}
|
651
|
+
|
652
|
+
|
653
|
+
|
654
|
+
|
655
|
+
|
656
|
+
|
657
|
+
- (void)addBannerConstraints {
|
658
|
+
self.bannerView.translatesAutoresizingMaskIntoConstraints = NO;
|
659
|
+
|
660
|
+
// Tambahkan constraint berdasarkan posisi
|
661
|
+
if ([Position isEqualToString:@"bottom-center"]) {
|
229
662
|
[self.viewController.view addConstraints:@[
|
230
|
-
[NSLayoutConstraint constraintWithItem:bannerView
|
663
|
+
[NSLayoutConstraint constraintWithItem:self.bannerView
|
231
664
|
attribute:NSLayoutAttributeBottom
|
232
665
|
relatedBy:NSLayoutRelationEqual
|
233
666
|
toItem:self.viewController.view.safeAreaLayoutGuide
|
234
667
|
attribute:NSLayoutAttributeBottom
|
235
668
|
multiplier:1
|
236
|
-
constant:0
|
237
|
-
[NSLayoutConstraint constraintWithItem:bannerView
|
669
|
+
constant:0],
|
670
|
+
[NSLayoutConstraint constraintWithItem:self.bannerView
|
238
671
|
attribute:NSLayoutAttributeCenterX
|
239
672
|
relatedBy:NSLayoutRelationEqual
|
240
673
|
toItem:self.viewController.view
|
@@ -242,15 +675,177 @@ BOOL UnderAgeOfConsent = NO;- (void)initialize:(CDVInvokedUrlCommand*)command {
|
|
242
675
|
multiplier:1
|
243
676
|
constant:0]
|
244
677
|
]];
|
245
|
-
} else {
|
678
|
+
} else if ([Position isEqualToString:@"top-center"]) {
|
246
679
|
[self.viewController.view addConstraints:@[
|
247
|
-
[NSLayoutConstraint constraintWithItem:bannerView
|
680
|
+
[NSLayoutConstraint constraintWithItem:self.bannerView
|
248
681
|
attribute:NSLayoutAttributeTop
|
249
682
|
relatedBy:NSLayoutRelationEqual
|
250
683
|
toItem:self.viewController.view.safeAreaLayoutGuide
|
251
684
|
attribute:NSLayoutAttributeTop
|
252
685
|
multiplier:1
|
253
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
|
+
}
|
696
|
+
}
|
697
|
+
|
698
|
+
|
699
|
+
|
700
|
+
|
701
|
+
|
702
|
+
|
703
|
+
|
704
|
+
|
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
|
+
}
|
783
|
+
|
784
|
+
|
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
|
+
}
|
807
|
+
|
808
|
+
|
809
|
+
|
810
|
+
|
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];
|
831
|
+
}
|
832
|
+
|
833
|
+
|
834
|
+
|
835
|
+
|
836
|
+
- (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],
|
254
849
|
[NSLayoutConstraint constraintWithItem:bannerView
|
255
850
|
attribute:NSLayoutAttributeCenterX
|
256
851
|
relatedBy:NSLayoutRelationEqual
|
@@ -259,265 +854,877 @@ BOOL UnderAgeOfConsent = NO;- (void)initialize:(CDVInvokedUrlCommand*)command {
|
|
259
854
|
multiplier:1
|
260
855
|
constant:0]
|
261
856
|
]];
|
262
|
-
}
|
263
|
-
|
264
|
-
|
265
|
-
|
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
|
+
}
|
897
|
+
}
|
898
|
+
- (void)hideBannerAd:(CDVInvokedUrlCommand *)command {
|
899
|
+
CDVPluginResult *pluginResult;
|
900
|
+
NSString *callbackId = command.callbackId;
|
901
|
+
if (self.bannerView) {
|
902
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
266
903
|
self.bannerView.hidden = YES;
|
267
904
|
[self fireEvent:@"" event:@"on.banner.hide" withData:nil];
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
[
|
273
|
-
}
|
274
|
-
|
275
|
-
|
276
|
-
|
905
|
+
});
|
906
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
907
|
+
} else {
|
908
|
+
pluginResult =
|
909
|
+
[CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
|
910
|
+
}
|
911
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
912
|
+
}
|
913
|
+
- (void)removeBannerAd:(CDVInvokedUrlCommand *)command {
|
914
|
+
CDVPluginResult *pluginResult;
|
915
|
+
NSString *callbackId = command.callbackId;
|
916
|
+
if (self.bannerView) {
|
917
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
277
918
|
self.bannerView.hidden = YES;
|
278
919
|
[self.bannerView removeFromSuperview];
|
279
920
|
self.bannerView = nil;
|
280
921
|
[self fireEvent:@"" event:@"on.banner.remove" withData:nil];
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
[
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
922
|
+
});
|
923
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
924
|
+
} else {
|
925
|
+
pluginResult =
|
926
|
+
[CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
|
927
|
+
}
|
928
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
929
|
+
}
|
930
|
+
- (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];
|
305
993
|
}
|
306
|
-
self.appOpenAd = ad;
|
307
|
-
self.appOpenAd.fullScreenContentDelegate = self;
|
308
|
-
[self fireEvent:@"" event:@"on.appOpenAd.loaded" withData:nil];
|
309
|
-
if (auto_Show){ if (self.appOpenAd && [self.appOpenAd
|
310
|
-
canPresentFromRootViewController:self.viewController
|
311
|
-
error:nil]) { [self.appOpenAd presentFromRootViewController:self.viewController]; } else {
|
312
|
-
[self fireEvent:@"" event:@"on.appOpenAd.failed.show" withData:nil];
|
313
|
-
}}
|
314
|
-
}]; pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
315
|
-
} [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];}- (void)showAppOpenAd:(CDVInvokedUrlCommand *)command {
|
316
|
-
CDVPluginResult *pluginResult;
|
317
|
-
NSString *callbackId = command.callbackId;
|
318
|
-
if (self.appOpenAd && [self.appOpenAd
|
319
|
-
canPresentFromRootViewController:self.viewController
|
320
|
-
error:nil]) { [self.appOpenAd presentFromRootViewController:self.viewController]; pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; } else { pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
|
321
|
-
[self fireEvent:@"" event:@"on.appOpenAd.failed.show" withData:nil];
|
322
994
|
}
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
995
|
+
}];
|
996
|
+
});
|
997
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
998
|
+
}
|
999
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
1000
|
+
}
|
1001
|
+
- (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];
|
1023
|
+
}
|
1024
|
+
- (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;
|
1067
|
+
[self fireEvent:@""
|
1068
|
+
event:@"on.interstitial.loaded"
|
1069
|
+
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];
|
1088
|
+
}
|
1089
|
+
- (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];
|
1111
|
+
}
|
1112
|
+
- (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;
|
1139
|
+
[self fireEvent:@""
|
1140
|
+
event:@"on.rewardedInt.loaded"
|
1141
|
+
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:^{
|
375
1150
|
GADAdReward *reward =
|
376
1151
|
self.rewardedInterstitialAd.adReward;
|
377
|
-
[self fireEvent:@""
|
1152
|
+
[self fireEvent:@""
|
1153
|
+
event:@"on.rewardedInt."
|
1154
|
+
@"userEarnedReward"
|
1155
|
+
withData:nil];
|
378
1156
|
isAdSkip = 2;
|
379
|
-
NSString *rewardMessage = [NSString
|
1157
|
+
NSString *rewardMessage = [NSString
|
1158
|
+
stringWithFormat:
|
1159
|
+
@"Reward received with "
|
380
1160
|
@"currency %@ , amount %ld",
|
381
|
-
reward.type,
|
382
|
-
|
383
|
-
|
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
|
+
}
|
384
1170
|
}
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
1171
|
+
}];
|
1172
|
+
});
|
1173
|
+
}
|
1174
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
1175
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
1176
|
+
}
|
1177
|
+
- (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];
|
1215
|
+
}
|
1216
|
+
- (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
|
1248
|
+
userDidEarnRewardHandler:^{
|
425
1249
|
GADAdReward *reward =
|
426
1250
|
self.rewardedAd.adReward;
|
427
|
-
[self fireEvent:@""
|
1251
|
+
[self fireEvent:@""
|
1252
|
+
event:@"on.reward.userEarnedReward"
|
1253
|
+
withData:nil];
|
428
1254
|
isAdSkip = 2;
|
429
|
-
NSString *rewardMessage = [NSString
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
[self fireEvent:@"" event:@"on.reward.userEarnedReward" withData:nil];
|
443
|
-
isAdSkip = 2;
|
444
|
-
NSString *rewardMessage = [NSString stringWithFormat:@"Reward received with currency %@ , amount %lf", reward.type, [reward.amount doubleValue]];
|
445
|
-
NSLog(@"%@", rewardMessage); }]; pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; } else {
|
446
|
-
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
|
447
|
-
[self fireEvent:@"" event:@"on.rewarded.failed.show" withData:nil];
|
448
|
-
} [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
449
|
-
}- (void) fireEvent:(NSString *)obj event:(NSString *)eventName withData:(NSString *)jsonStr {
|
450
|
-
NSString* js;
|
451
|
-
if(obj && [obj isEqualToString:@"window"]) {
|
452
|
-
js = [NSString stringWithFormat:@"var evt=document.createEvent(\"UIEvents\");evt.initUIEvent(\"%@\",true,false,window,0);window.dispatchEvent(evt);", eventName];
|
453
|
-
} else if(jsonStr && [jsonStr length]>0) {
|
454
|
-
js = [NSString stringWithFormat:@"javascript:cordova.fireDocumentEvent('%@',%@);", eventName, jsonStr];
|
455
|
-
} else {
|
456
|
-
js = [NSString stringWithFormat:@"javascript:cordova.fireDocumentEvent('%@');", eventName];
|
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
|
+
}
|
457
1268
|
}
|
458
|
-
|
459
|
-
|
1269
|
+
}];
|
1270
|
+
});
|
1271
|
+
}
|
1272
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
1273
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
1274
|
+
}
|
1275
|
+
- (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];
|
1311
|
+
}
|
1312
|
+
- (void)fireEvent:(NSString *)obj
|
1313
|
+
event:(NSString *)eventName
|
1314
|
+
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];
|
1358
|
+
}
|
1359
|
+
|
1360
|
+
- (NSString *)__getAdMobDeviceId {
|
1361
|
+
NSUUID *adid = [[ASIdentifierManager sharedManager] advertisingIdentifier];
|
1362
|
+
return [self __md5:adid.UUIDString];
|
1363
|
+
}
|
1364
|
+
|
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;
|
1381
|
+
}
|
1382
|
+
|
460
1383
|
#pragma mark GADBannerViewDelegate implementation
|
461
|
-
-(void)bannerViewDidReceiveAd:(GADBannerView *)bannerView {
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
1384
|
+
- (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];
|
1396
|
+
}
|
1397
|
+
|
1398
|
+
[self fireEvent:@""
|
1399
|
+
event:@"on."
|
1400
|
+
@"banner"
|
1401
|
+
@".load"
|
1402
|
+
withData:nil];
|
1403
|
+
NSLog(@"bannerViewDidR"
|
1404
|
+
@"eceiveAd");
|
1405
|
+
if (auto_Show) {
|
1406
|
+
if (self.bannerView) {
|
466
1407
|
[self addBannerViewToView:command];
|
467
1408
|
self.bannerView.hidden = NO;
|
468
1409
|
}
|
469
|
-
} else {
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
NSLog(@"bannerViewWillPresentScreen");
|
479
|
-
}- (void)bannerViewWillDismissScreen:(GADBannerView *)bannerView {
|
480
|
-
[self fireEvent:@"" event:@"on.banner.close" withData:nil];
|
481
|
-
NSLog(@"bannerViewWillDismissScreen");
|
482
|
-
}- (void)bannerViewDidDismissScreen:(GADBannerView *)bannerView {
|
483
|
-
[self fireEvent:@"" event:@"on.banner.did.dismiss" withData:nil];
|
484
|
-
NSLog(@"bannerViewDidDismissScreen");
|
1410
|
+
} else {
|
1411
|
+
[self fireEvent:@""
|
1412
|
+
event:@"on."
|
1413
|
+
@"bann"
|
1414
|
+
@"er."
|
1415
|
+
@"fail"
|
1416
|
+
@"ed."
|
1417
|
+
@"show"
|
1418
|
+
withData:nil];
|
485
1419
|
}
|
1420
|
+
}
|
1421
|
+
- (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]);
|
1434
|
+
}
|
1435
|
+
- (void)bannerViewDidRecordImpression:(GADBannerView *)bannerView {
|
1436
|
+
[self fireEvent:@""
|
1437
|
+
event:@"on."
|
1438
|
+
@"banner"
|
1439
|
+
@".impre"
|
1440
|
+
@"ssion"
|
1441
|
+
withData:nil];
|
1442
|
+
NSLog(@"bannerViewD"
|
1443
|
+
@"idRecordImp"
|
1444
|
+
@"ression");
|
1445
|
+
}
|
1446
|
+
- (void)bannerViewWillPresentScreen:(GADBannerView *)bannerView {
|
1447
|
+
[self fireEvent:@""
|
1448
|
+
event:@"on."
|
1449
|
+
@"banner"
|
1450
|
+
@".open"
|
1451
|
+
withData:nil];
|
1452
|
+
NSLog(@"bannerViewW"
|
1453
|
+
@"illPresentS"
|
1454
|
+
@"creen");
|
1455
|
+
}
|
1456
|
+
- (void)bannerViewWillDismissScreen:(GADBannerView *)bannerView {
|
1457
|
+
[self fireEvent:@""
|
1458
|
+
event:@"on."
|
1459
|
+
@"banner"
|
1460
|
+
@".close"
|
1461
|
+
withData:nil];
|
1462
|
+
NSLog(@"bannerViewW"
|
1463
|
+
@"illDismissS"
|
1464
|
+
@"creen");
|
1465
|
+
}
|
1466
|
+
- (void)bannerViewDidDismissScreen:(GADBannerView *)bannerView {
|
1467
|
+
[self fireEvent:@""
|
1468
|
+
event:@"on."
|
1469
|
+
@"banner"
|
1470
|
+
@".did."
|
1471
|
+
@"dismis"
|
1472
|
+
@"s"
|
1473
|
+
withData:nil];
|
1474
|
+
NSLog(@"bannerViewDidD"
|
1475
|
+
@"ismissScreen");
|
1476
|
+
}
|
486
1477
|
#pragma GADFullScreeContentDelegate implementation
|
487
|
-
- (void)adWillPresentFullScreenContent:(id)ad {
|
488
|
-
|
489
|
-
[self fireEvent:@""
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
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
|
+
}
|
1543
|
+
}
|
1544
|
+
- (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
|
+
}
|
1620
|
+
}
|
1621
|
+
|
1622
|
+
- (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.");
|
1713
|
+
}
|
1714
|
+
}
|
515
1715
|
#pragma mark Cleanup
|
516
|
-
- (void)dealloc
|
1716
|
+
- (void)dealloc
|
1717
|
+
{
|
517
1718
|
self.appOpenAd = nil;
|
518
|
-
self.bannerView
|
519
|
-
|
520
|
-
self.
|
521
|
-
|
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];
|
522
1728
|
}
|
523
1729
|
@end
|
1730
|
+
|