emi-indo-cordova-plugin-admob 1.4.2 → 1.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +522 -248
- package/example/Advanced topics/{consent_GDPR_IAB_TFCv2.2.html → IABTFC.html } +22 -114
- package/example/Advanced topics/consent.html +47 -35
- package/example/Advanced topics/globalSettings.html +17 -8
- package/example/Advanced topics/requestIDFA.html +59 -0
- package/example/Advanced topics/targeting.html +14 -28
- package/example/app_open_ads.html +20 -43
- package/example/banner_ads.html +62 -97
- package/example/interstitial_ads.html +28 -44
- package/example/rewarded_ads.html +29 -45
- package/example/rewarded_interstitial_ads.html +27 -44
- package/example/wewrtr.html +0 -0
- package/package.json +1 -1
- package/plugin.xml +3 -3
- package/src/android/emiAdmobPlugin.java +1 -1
- package/src/ios/emiAdmobPlugin.h +3 -2
- package/src/ios/emiAdmobPlugin.m +371 -515
- package/www/emiAdmobPlugin.js +24 -23
- package/example/Advanced topics/auto_load_and_show.html +0 -94
package/src/ios/emiAdmobPlugin.m
CHANGED
@@ -22,196 +22,141 @@ NSString *Npa = @"1";
|
|
22
22
|
NSString *Position = @"bottom";
|
23
23
|
BOOL EnableCollapsible = NO;
|
24
24
|
BOOL ResponseInfo = NO;
|
25
|
+
int isAdSkip = 0;
|
25
26
|
BOOL isIAB = NO;
|
26
|
-
|
27
|
-
NSString* js;
|
28
|
-
if(obj && [obj isEqualToString:@"window"]) {
|
29
|
-
js = [NSString stringWithFormat:@"var evt=document.createEvent(\"UIEvents\");evt.initUIEvent(\"%@\",true,false,window,0);window.dispatchEvent(evt);", eventName];
|
30
|
-
} else if(jsonStr && [jsonStr length]>0) {
|
31
|
-
js = [NSString stringWithFormat:@"javascript:cordova.fireDocumentEvent('%@',%@);", eventName, jsonStr];
|
32
|
-
} else {
|
33
|
-
js = [NSString stringWithFormat:@"javascript:cordova.fireDocumentEvent('%@');", eventName];
|
34
|
-
}
|
35
|
-
[self.commandDelegate evalJs:js];
|
36
|
-
}
|
37
|
-
- (void)pluginInitialize {
|
38
|
-
isIAB = YES;
|
39
|
-
[[NSUserDefaults standardUserDefaults] synchronize];
|
40
|
-
}
|
41
|
-
- (void)initialize:(CDVInvokedUrlCommand*)command {
|
42
|
-
GADMobileAds *ads = [GADMobileAds sharedInstance];
|
27
|
+
BOOL UnderAgeOfConsent = NO;- (void)initialize:(CDVInvokedUrlCommand*)command { GADMobileAds *ads = [GADMobileAds sharedInstance];
|
43
28
|
[ads startWithCompletionHandler:^(GADInitializationStatus *status) {
|
44
29
|
// Optional: Log each adapter's initialization latency.
|
45
30
|
NSDictionary *adapterStatuses = [status adapterStatusesByClassName];
|
46
31
|
for (NSString *adapter in adapterStatuses) {
|
47
32
|
GADAdapterStatus *adapterStatus = adapterStatuses[adapter];
|
48
33
|
NSLog(@"Adapter Name: %@, Description: %@, Latency: %f", adapter,
|
49
|
-
adapterStatus.description, adapterStatus.latency);
|
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
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
}
|
175
|
-
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:exception.reason];
|
176
|
-
}
|
177
|
-
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
178
|
-
}
|
179
|
-
- (void)globalSettings:(CDVInvokedUrlCommand*)command {
|
180
|
-
CDVPluginResult *pluginResult;
|
181
|
-
NSString *callbackId = command.callbackId;
|
182
|
-
BOOL setAppMuted = [[command argumentAtIndex:0] boolValue];
|
183
|
-
float setAppVolume = [[command argumentAtIndex:1] floatValue];
|
184
|
-
NSString* npa = [command.arguments objectAtIndex:2];
|
185
|
-
BOOL enableCollapsible = [[command argumentAtIndex:3] boolValue];
|
186
|
-
BOOL responseInfo = [[command argumentAtIndex:4] boolValue];
|
187
|
-
@try {
|
188
|
-
GADMobileAds.sharedInstance.applicationVolume = setAppVolume;
|
189
|
-
GADMobileAds.sharedInstance.applicationMuted = setAppMuted;
|
190
|
-
Npa = npa;
|
191
|
-
EnableCollapsible = enableCollapsible;
|
192
|
-
ResponseInfo = responseInfo;
|
193
|
-
}@catch (NSException *exception) {
|
194
|
-
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:exception.reason];
|
195
|
-
}
|
196
|
-
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
197
|
-
}
|
198
|
-
- (void)targeting:(CDVInvokedUrlCommand*)command {
|
199
|
-
CDVPluginResult *pluginResult;
|
200
|
-
NSString *callbackId = command.callbackId;
|
201
|
-
NSNumber *TagForChildDirectedTreatment = [command argumentAtIndex:0];
|
202
|
-
NSNumber *tagForUnderAgeOfConsent = [command argumentAtIndex:1];
|
203
|
-
NSString *maxAdContentRating = [command argumentAtIndex:2];
|
204
|
-
@try {
|
205
|
-
GADRequestConfiguration *requestConfiguration = GADMobileAds.sharedInstance.requestConfiguration;
|
206
|
-
requestConfiguration.tagForChildDirectedTreatment = TagForChildDirectedTreatment;
|
207
|
-
requestConfiguration.tagForUnderAgeOfConsent = tagForUnderAgeOfConsent;
|
208
|
-
requestConfiguration.maxAdContentRating = maxAdContentRating;
|
209
|
-
}@catch (NSException *exception) {
|
210
|
-
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:exception.reason];
|
211
|
-
}
|
212
|
-
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
213
|
-
}
|
214
|
-
- (GADAdSize)__AdSizeFromString:(NSString *)size
|
34
|
+
adapterStatus.description, adapterStatus.latency); } [self fireEvent:@"" event:@"on.sdkInitialization" withData:nil]; }];}- (void)requestIDFA:(CDVInvokedUrlCommand*)command { CDVPluginResult *pluginResult;
|
35
|
+
NSString *callbackId = command.callbackId; if (@available(iOS 14, *)) {
|
36
|
+
[ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status) {
|
37
|
+
if (status == ATTrackingManagerAuthorizationStatusDenied) { idfaStatus = ATTrackingManagerAuthorizationStatusDenied;
|
38
|
+
} else if (status == ATTrackingManagerAuthorizationStatusAuthorized) { idfaStatus = ATTrackingManagerAuthorizationStatusAuthorized;
|
39
|
+
} else if (status == ATTrackingManagerAuthorizationStatusRestricted) { idfaStatus = ATTrackingManagerAuthorizationStatusRestricted;
|
40
|
+
} else if (status == ATTrackingManagerAuthorizationStatusNotDetermined) { idfaStatus = ATTrackingManagerAuthorizationStatusNotDetermined;
|
41
|
+
}
|
42
|
+
}]; [self fireEvent:@"" event:@"on.getIDFA.status" withData:nil]; pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt:idfaStatus];
|
43
|
+
} else { [self fireEvent:@"" event:@"on.getIDFA.error" withData:nil];
|
44
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR]; } [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
45
|
+
}- (void)getConsentRequest:(CDVInvokedUrlCommand*)command {
|
46
|
+
CDVPluginResult *pluginResult;
|
47
|
+
NSString *callbackId = command.callbackId;
|
48
|
+
UMPRequestParameters *parameters = [[UMPRequestParameters alloc] init];
|
49
|
+
// UMPDebugSettings *debugSettings = [[UMPDebugSettings alloc] init];
|
50
|
+
// debugSettings.testDeviceIdentifiers = @[@"59156CDC-B042-4D81-A9FA-900869782912"];
|
51
|
+
// parameters.debugSettings = debugSettings;
|
52
|
+
// debugSettings.geography = UMPDebugGeographyEEA;
|
53
|
+
// BOOL tagForUnderAgeOfConsent = [[command argumentAtIndex:0] boolValue];
|
54
|
+
parameters.tagForUnderAgeOfConsent = UnderAgeOfConsent; [UMPConsentInformation.sharedInstance
|
55
|
+
requestConsentInfoUpdateWithParameters:parameters
|
56
|
+
completionHandler:^(NSError *_Nullable requestConsentError) {
|
57
|
+
if (requestConsentError) {
|
58
|
+
// Consent gathering failed.
|
59
|
+
NSLog(@"Error: %@", requestConsentError.localizedDescription);
|
60
|
+
return;
|
61
|
+
} [UMPConsentForm loadAndPresentIfRequiredFromViewController:self.viewController
|
62
|
+
completionHandler:^(NSError *loadAndPresentError) {
|
63
|
+
if (loadAndPresentError) {
|
64
|
+
// Consent gathering failed.
|
65
|
+
NSLog(@"Error: %@", loadAndPresentError.localizedDescription);
|
66
|
+
return;
|
67
|
+
} UMPFormStatus formStatus = UMPConsentInformation.sharedInstance.formStatus; if (formStatus == UMPFormStatusUnknown) { fromStatus = 0; } else if (formStatus == UMPFormStatusAvailable) { fromStatus = 1; } else if (formStatus == UMPFormStatusUnavailable) { fromStatus = 2;
|
68
|
+
} [self fireEvent:@"" event:@"on.get.from.status" withData:nil]; }]; }]; pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt:fromStatus]; [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
69
|
+
}- (void)showPrivacyOptionsForm:(CDVInvokedUrlCommand*)command { UMPRequestParameters *parameters = [[UMPRequestParameters alloc] init];
|
70
|
+
// UMPDebugSettings *debugSettings = [[UMPDebugSettings alloc] init];
|
71
|
+
// debugSettings.testDeviceIdentifiers = @[@"59156CDC-B042-4D81-A9FA-900869782912"];
|
72
|
+
// parameters.debugSettings = debugSettings;
|
73
|
+
// debugSettings.geography = UMPDebugGeographyEEA;
|
74
|
+
// BOOL tagForUnderAgeOfConsent = [[command argumentAtIndex:0] boolValue];
|
75
|
+
parameters.tagForUnderAgeOfConsent = UnderAgeOfConsent;
|
76
|
+
[UMPConsentInformation.sharedInstance
|
77
|
+
requestConsentInfoUpdateWithParameters:parameters
|
78
|
+
completionHandler:^(NSError *_Nullable requestConsentError) {
|
79
|
+
// ...
|
80
|
+
[UMPConsentForm loadAndPresentIfRequiredFromViewController:self.viewController
|
81
|
+
completionHandler:^(NSError *loadAndPresentError) { }]; [self isPrivacyOptionsRequired]; }]; [UMPConsentForm presentPrivacyOptionsFormFromViewController:self.viewController completionHandler:^(NSError * _Nullable formError) {
|
82
|
+
if (formError) {
|
83
|
+
// Handle the error.
|
84
|
+
NSLog(@"Error: %@", formError.localizedDescription);
|
85
|
+
[self fireEvent:@"" event:@"on.getPrivacyOptionsFrom.error" withData:nil];
|
86
|
+
}
|
87
|
+
}];}- (BOOL)isPrivacyOptionsRequired {
|
88
|
+
return UMPConsentInformation.sharedInstance.privacyOptionsRequirementStatus ==
|
89
|
+
UMPPrivacyOptionsRequirementStatusRequired;
|
90
|
+
}- (void)pluginInitialize { isIAB = YES; NSMutableDictionary* result = [[NSMutableDictionary alloc] init];
|
91
|
+
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults]; NSNumber* CmpSdkID = [prefs valueForKey:@"IABTCF_CmpSdkID"];
|
92
|
+
NSString *gdprApplies = [prefs stringForKey:@"IABTCF_gdprApplies"];
|
93
|
+
NSString *PurposeConsents = [prefs stringForKey:@"IABTCF_PurposeConsents"];
|
94
|
+
NSString *TCString = [prefs stringForKey:@"IABTCF_TCString"];
|
95
|
+
result[@"IABTCF_CmpSdkID"] = CmpSdkID;
|
96
|
+
result[@"IABTCF_gdprApplies"] = gdprApplies;
|
97
|
+
result[@"IABTCF_PurposeConsents"] = PurposeConsents;
|
98
|
+
result[@"IABTCF_TCString"] = TCString; NSLog(@"%@", [[NSUserDefaults standardUserDefaults] dictionaryRepresentation]);
|
99
|
+
[prefs synchronize];}- (void)getIabTfc:(CDVInvokedUrlCommand*)command {
|
100
|
+
CDVPluginResult *pluginResult;
|
101
|
+
NSString *callbackId = command.callbackId;
|
102
|
+
if (isIAB == 1) {
|
103
|
+
NSMutableDictionary* result = [[NSMutableDictionary alloc] init];
|
104
|
+
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults]; NSNumber* CmpSdkID = [prefs valueForKey:@"IABTCF_CmpSdkID"];
|
105
|
+
NSString *gdprApplies = [prefs stringForKey:@"IABTCF_gdprApplies"];
|
106
|
+
NSString *PurposeConsents = [prefs stringForKey:@"IABTCF_PurposeConsents"];
|
107
|
+
NSString *TCString = [prefs stringForKey:@"IABTCF_TCString"]; result[@"IABTCF_CmpSdkID"] = CmpSdkID;
|
108
|
+
result[@"IABTCF_gdprApplies"] = gdprApplies;
|
109
|
+
result[@"IABTCF_PurposeConsents"] = PurposeConsents;
|
110
|
+
result[@"IABTCF_TCString"] = TCString; [[NSUserDefaults standardUserDefaults] synchronize]; NSLog(@"%@", [[NSUserDefaults standardUserDefaults] dictionaryRepresentation]);
|
111
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:result];
|
112
|
+
[self fireEvent:@"" event:@"on.getIabTfc" withData:nil]; } else { pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
|
113
|
+
} [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
114
|
+
}- (void)consentReset:(CDVInvokedUrlCommand*)command {
|
115
|
+
CDVPluginResult *pluginResult;
|
116
|
+
NSString *callbackId = command.callbackId;
|
117
|
+
@try {
|
118
|
+
[[UMPConsentInformation sharedInstance] reset];
|
119
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
120
|
+
}@catch (NSException *exception) {
|
121
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:exception.reason];
|
122
|
+
}
|
123
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
124
|
+
}- (void)setPublisherFirstPartyIDEnabled:(BOOL)enabled{};- (void)globalSettings:(CDVInvokedUrlCommand*)command {
|
125
|
+
CDVPluginResult *pluginResult;
|
126
|
+
NSString *callbackId = command.callbackId;
|
127
|
+
BOOL setAppMuted = [[command argumentAtIndex:0] boolValue];
|
128
|
+
float setAppVolume = [[command argumentAtIndex:1] floatValue];
|
129
|
+
BOOL publisherFirstPartyIdEnabled = [[command argumentAtIndex:3] boolValue];
|
130
|
+
NSString* npa = [command.arguments objectAtIndex:2];
|
131
|
+
BOOL enableCollapsible = [[command argumentAtIndex:3] boolValue];
|
132
|
+
BOOL responseInfo = [[command argumentAtIndex:4] boolValue];
|
133
|
+
@try {
|
134
|
+
GADMobileAds.sharedInstance.applicationVolume = setAppVolume;
|
135
|
+
GADMobileAds.sharedInstance.applicationMuted = setAppMuted;
|
136
|
+
[self setPublisherFirstPartyIDEnabled:publisherFirstPartyIdEnabled];
|
137
|
+
Npa = npa;
|
138
|
+
EnableCollapsible = enableCollapsible;
|
139
|
+
ResponseInfo = responseInfo;
|
140
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
141
|
+
}@catch (NSException *exception) {
|
142
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:exception.reason];
|
143
|
+
}
|
144
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
145
|
+
}- (void)targeting:(CDVInvokedUrlCommand*)command {
|
146
|
+
CDVPluginResult *pluginResult;
|
147
|
+
NSString *callbackId = command.callbackId;
|
148
|
+
NSNumber *childDirectedTreatment = [command argumentAtIndex:0];
|
149
|
+
NSNumber *underAgeOfConsent = [command argumentAtIndex:1];
|
150
|
+
NSString *contentRating = [command argumentAtIndex:2];
|
151
|
+
@try {
|
152
|
+
GADRequestConfiguration *requestConfiguration = GADMobileAds.sharedInstance.requestConfiguration;
|
153
|
+
requestConfiguration.tagForChildDirectedTreatment = childDirectedTreatment;
|
154
|
+
requestConfiguration.tagForUnderAgeOfConsent = underAgeOfConsent;
|
155
|
+
requestConfiguration.maxAdContentRating = contentRating;
|
156
|
+
UnderAgeOfConsent = underAgeOfConsent;
|
157
|
+
}@catch (NSException *exception) {
|
158
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:exception.reason];
|
159
|
+
} [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];}- (GADAdSize)__AdSizeFromString:(NSString *)size
|
215
160
|
{
|
216
161
|
if ([size isEqualToString:@"ANCHORED"]) {
|
217
162
|
return GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth(adWidth);
|
@@ -228,23 +173,17 @@ BOOL isIAB = NO;
|
|
228
173
|
} else {
|
229
174
|
return GADAdSizeBanner;
|
230
175
|
}
|
231
|
-
}
|
232
|
-
- (void)loadBannerAd:(CDVInvokedUrlCommand*)command {
|
176
|
+
}- (void)loadBannerAd:(CDVInvokedUrlCommand*)command {
|
233
177
|
if(self.bannerView) {
|
234
178
|
NSLog(@"Admob banner has been initing");
|
235
179
|
return;
|
236
180
|
}
|
237
181
|
CDVPluginResult *pluginResult;
|
238
|
-
NSString *callbackId = command.callbackId;
|
239
|
-
adFormat = 3;
|
240
|
-
if (adFormat == 3) {
|
241
|
-
UIView *parentView = [self.webView superview];
|
242
|
-
NSString* adUnitId = [command.arguments objectAtIndex:0];
|
182
|
+
NSString *callbackId = command.callbackId; adFormat = 3; if (adFormat == 3) { UIView *parentView = [self.webView superview]; NSString* adUnitId = [command.arguments objectAtIndex:0];
|
243
183
|
// NSNumber* x = [command.arguments objectAtIndex:1];
|
244
184
|
// NSNumber* y = [command.arguments objectAtIndex:2];
|
245
185
|
NSString* position = [command.arguments objectAtIndex:1];
|
246
|
-
NSString* size = [command.arguments objectAtIndex:2];
|
247
|
-
NSString* collapsible = [command.arguments objectAtIndex:3];
|
186
|
+
NSString* size = [command.arguments objectAtIndex:2]; NSString* collapsible = [command.arguments objectAtIndex:3];
|
248
187
|
NSNumber* adaptive_Width = [command.arguments objectAtIndex:4];
|
249
188
|
BOOL autoShow = [[command argumentAtIndex:5] boolValue];
|
250
189
|
auto_Show = autoShow;
|
@@ -253,11 +192,9 @@ BOOL isIAB = NO;
|
|
253
192
|
Position = position;
|
254
193
|
// float posX = [x floatValue];
|
255
194
|
// float posY = [y floatValue];
|
256
|
-
GADAdSize sizes = [self __AdSizeFromString:size];
|
257
|
-
// CGPoint origin = CGPointMake(posX,posY);
|
195
|
+
GADAdSize sizes = [self __AdSizeFromString:size]; // CGPoint origin = CGPointMake(posX,posY);
|
258
196
|
self.bannerView = [[GADBannerView alloc]
|
259
|
-
|
260
|
-
GADRequest *request = [GADRequest request];
|
197
|
+
initWithAdSize:sizes]; GADRequest *request = [GADRequest request];
|
261
198
|
GADExtras *extras = [[GADExtras alloc] init];
|
262
199
|
if (EnableCollapsible){
|
263
200
|
extras.additionalParameters = @{@"collapsible" : collapsible};
|
@@ -270,31 +207,25 @@ BOOL isIAB = NO;
|
|
270
207
|
[self.bannerView loadRequest:request];
|
271
208
|
self.bannerView.hidden = YES;
|
272
209
|
[parentView addSubview:self.bannerView];
|
273
|
-
[parentView bringSubviewToFront:self.bannerView];
|
274
|
-
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
210
|
+
[parentView bringSubviewToFront:self.bannerView]; pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
275
211
|
} else {
|
276
212
|
NSLog(@"Admob Option invalid for banner");
|
277
213
|
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
|
278
214
|
}
|
279
215
|
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
280
|
-
}
|
281
|
-
- (void)showBannerAd:(CDVInvokedUrlCommand*)command {
|
216
|
+
}- (void)showBannerAd:(CDVInvokedUrlCommand*)command {
|
282
217
|
CDVPluginResult *pluginResult;
|
283
218
|
NSString *callbackId = command.callbackId;
|
284
219
|
if(self.bannerView) {
|
285
|
-
self.bannerView.hidden = NO;
|
286
|
-
[self addBannerViewToView:command];
|
287
|
-
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
220
|
+
self.bannerView.hidden = NO; [self addBannerViewToView:command]; pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
288
221
|
} else {
|
289
222
|
[self fireEvent:@"" event:@"on.banner.failed.show" withData:nil];
|
290
223
|
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
|
291
224
|
}
|
292
225
|
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
293
|
-
}
|
294
|
-
- (void)addBannerViewToView:(CDVInvokedUrlCommand*)command{
|
295
|
-
bannerView.translatesAutoresizingMaskIntoConstraints = NO;
|
226
|
+
}- (void)addBannerViewToView:(CDVInvokedUrlCommand*)command{ bannerView.translatesAutoresizingMaskIntoConstraints = NO;
|
296
227
|
[self.viewController.view addSubview:bannerView];
|
297
|
-
if ([Position isEqualToString:@"bottom"]){
|
228
|
+
if ([Position isEqualToString:@"bottom-center"]){
|
298
229
|
[self.viewController.view addConstraints:@[
|
299
230
|
[NSLayoutConstraint constraintWithItem:bannerView
|
300
231
|
attribute:NSLayoutAttributeBottom
|
@@ -302,8 +233,7 @@ BOOL isIAB = NO;
|
|
302
233
|
toItem:self.viewController.view.safeAreaLayoutGuide
|
303
234
|
attribute:NSLayoutAttributeBottom
|
304
235
|
multiplier:1
|
305
|
-
constant:0
|
306
|
-
],
|
236
|
+
constant:0 ],
|
307
237
|
[NSLayoutConstraint constraintWithItem:bannerView
|
308
238
|
attribute:NSLayoutAttributeCenterX
|
309
239
|
relatedBy:NSLayoutRelationEqual
|
@@ -329,333 +259,259 @@ BOOL isIAB = NO;
|
|
329
259
|
multiplier:1
|
330
260
|
constant:0]
|
331
261
|
]];
|
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
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
262
|
+
}}- (void)hideBannerAd:(CDVInvokedUrlCommand*)command {
|
263
|
+
CDVPluginResult *pluginResult;
|
264
|
+
NSString *callbackId = command.callbackId;
|
265
|
+
if(self.bannerView) {
|
266
|
+
self.bannerView.hidden = YES;
|
267
|
+
[self fireEvent:@"" event:@"on.banner.hide" withData:nil];
|
268
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
269
|
+
} else {
|
270
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
|
271
|
+
}
|
272
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
273
|
+
}- (void)removeBannerAd:(CDVInvokedUrlCommand*)command {
|
274
|
+
CDVPluginResult *pluginResult;
|
275
|
+
NSString *callbackId = command.callbackId;
|
276
|
+
if(self.bannerView) {
|
277
|
+
self.bannerView.hidden = YES;
|
278
|
+
[self.bannerView removeFromSuperview];
|
279
|
+
self.bannerView = nil;
|
280
|
+
[self fireEvent:@"" event:@"on.banner.remove" withData:nil];
|
281
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
282
|
+
} else {
|
283
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
|
284
|
+
}
|
285
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];}- (void)loadAppOpenAd:(CDVInvokedUrlCommand *)command {
|
286
|
+
CDVPluginResult *pluginResult;
|
287
|
+
NSString *callbackId = command.callbackId;
|
288
|
+
NSString* adUnitId = [command.arguments objectAtIndex:0];
|
289
|
+
BOOL autoShow = [[command argumentAtIndex:1] boolValue];
|
290
|
+
auto_Show = autoShow;
|
291
|
+
adFormat = 1;
|
292
|
+
self.appOpenAd = nil;
|
293
|
+
if (adFormat == 1){
|
294
|
+
GADRequest *request = [GADRequest request];
|
295
|
+
GADExtras *extras = [[GADExtras alloc] init];
|
296
|
+
extras.additionalParameters = @{@"npa": Npa};
|
297
|
+
[request registerAdNetworkExtras:extras];
|
298
|
+
[GADAppOpenAd loadWithAdUnitID:adUnitId
|
299
|
+
request:request
|
300
|
+
orientation:UIInterfaceOrientationPortrait
|
301
|
+
completionHandler:^(GADAppOpenAd *ad, NSError *error) {
|
302
|
+
if (error) {
|
303
|
+
[self fireEvent:@"" event:@"on.appOpenAd.failed.loaded" withData:nil];
|
304
|
+
NSLog(@"Failed to load App Open Ad ad with error: %@", [error localizedDescription]); return;
|
305
|
+
}
|
306
|
+
self.appOpenAd = ad;
|
307
|
+
self.appOpenAd.fullScreenContentDelegate = self;
|
308
|
+
[self fireEvent:@"" event:@"on.appOpenAd.loaded" withData:nil];
|
309
|
+
if (auto_Show){ if (self.appOpenAd && [self.appOpenAd
|
310
|
+
canPresentFromRootViewController:self.viewController
|
311
|
+
error:nil]) { [self.appOpenAd presentFromRootViewController:self.viewController]; } else {
|
312
|
+
[self fireEvent:@"" event:@"on.appOpenAd.failed.show" withData:nil];
|
313
|
+
}}
|
314
|
+
}]; pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
315
|
+
} [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];}- (void)showAppOpenAd:(CDVInvokedUrlCommand *)command {
|
316
|
+
CDVPluginResult *pluginResult;
|
317
|
+
NSString *callbackId = command.callbackId;
|
386
318
|
if (self.appOpenAd && [self.appOpenAd
|
387
319
|
canPresentFromRootViewController:self.viewController
|
388
|
-
error:nil]) { [self.appOpenAd presentFromRootViewController:self.viewController];
|
389
|
-
} else {
|
320
|
+
error:nil]) { [self.appOpenAd presentFromRootViewController:self.viewController]; pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; } else { pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
|
390
321
|
[self fireEvent:@"" event:@"on.appOpenAd.failed.show" withData:nil];
|
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
|
-
if (adFormat == 2){
|
418
|
-
GADRequest *request = [GADRequest request];
|
419
|
-
[GADInterstitialAd
|
420
|
-
loadWithAdUnitID:adUnitId
|
421
|
-
request:request
|
422
|
-
completionHandler:^(GADInterstitialAd *ad, NSError *error) {
|
423
|
-
if (error) {
|
424
|
-
NSLog(@"Failed to load interstitial ad with error: %@", [error localizedDescription]);
|
425
|
-
// [self fireEvent:@"" event:@"on.interstitial.failed.load" withData:nil];
|
426
|
-
return;
|
427
|
-
}
|
428
|
-
self.interstitial = ad;
|
429
|
-
self.interstitial.fullScreenContentDelegate = self;
|
430
|
-
[self fireEvent:@"" event:@"on.interstitial.loaded" withData:nil];
|
431
|
-
if (auto_Show){
|
322
|
+
}
|
323
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
324
|
+
}- (void)loadInterstitialAd:(CDVInvokedUrlCommand *)command {
|
325
|
+
CDVPluginResult *pluginResult;
|
326
|
+
NSString *callbackId = command.callbackId;
|
327
|
+
NSString* adUnitId = [command.arguments objectAtIndex:0];
|
328
|
+
BOOL autoShow = [[command argumentAtIndex:1] boolValue];
|
329
|
+
auto_Show = autoShow;
|
330
|
+
adFormat = 2;
|
331
|
+
if (adFormat == 2){
|
332
|
+
GADRequest *request = [GADRequest request];
|
333
|
+
[GADInterstitialAd
|
334
|
+
loadWithAdUnitID:adUnitId
|
335
|
+
request:request
|
336
|
+
completionHandler:^(GADInterstitialAd *ad, NSError *error) {
|
337
|
+
if (error) { NSLog(@"Failed to load interstitial ad with error: %@", [error localizedDescription]);
|
338
|
+
// [self fireEvent:@"" event:@"on.interstitial.failed.load" withData:nil]; return;
|
339
|
+
} self.interstitial = ad;
|
340
|
+
self.interstitial.fullScreenContentDelegate = self;
|
341
|
+
[self fireEvent:@"" event:@"on.interstitial.loaded" withData:nil]; if (auto_Show){ if (self.interstitial && [self.interstitial
|
342
|
+
canPresentFromRootViewController:self.viewController error:nil]) { [self.interstitial presentFromRootViewController:self.viewController]; } else { [self fireEvent:@"" event:@"on.interstitial.failed.show" withData:nil];
|
343
|
+
} } }];
|
344
|
+
} pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
345
|
+
}- (void)showInterstitialAd:(CDVInvokedUrlCommand *)command {
|
346
|
+
CDVPluginResult *pluginResult;
|
347
|
+
NSString *callbackId = command.callbackId;
|
432
348
|
if (self.interstitial && [self.interstitial
|
433
|
-
canPresentFromRootViewController:self.viewController error:nil]) {
|
434
|
-
[
|
349
|
+
canPresentFromRootViewController:self.viewController error:nil]) { [self.interstitial presentFromRootViewController:self.viewController];
|
350
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
435
351
|
} else {
|
352
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
|
436
353
|
[self fireEvent:@"" event:@"on.interstitial.failed.show" withData:nil];
|
354
|
+
} [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
355
|
+
}- (void)loadRewardedInterstitialAd:(CDVInvokedUrlCommand*)command { CDVPluginResult *pluginResult;
|
356
|
+
NSString *callbackId = command.callbackId;
|
357
|
+
NSString* adUnitId = [command.arguments objectAtIndex:0];
|
358
|
+
BOOL autoShow = [[command argumentAtIndex:1] boolValue];
|
359
|
+
auto_Show = autoShow;
|
360
|
+
adFormat = 4;
|
361
|
+
if (adFormat == 4){ GADRequest *request = [GADRequest request];
|
362
|
+
[GADRewardedInterstitialAd
|
363
|
+
loadWithAdUnitID:adUnitId
|
364
|
+
request:request
|
365
|
+
completionHandler:^(GADRewardedInterstitialAd *ad, NSError *error) {
|
366
|
+
if (error) {
|
367
|
+
NSLog(@"Rewarded ad failed to load with error: %@", [error localizedDescription]);
|
368
|
+
return;
|
369
|
+
}
|
370
|
+
self.rewardedInterstitialAd = ad; isAdSkip = 1;
|
371
|
+
NSLog(@"Rewarded ad loaded.");
|
372
|
+
self.rewardedInterstitialAd.fullScreenContentDelegate = self;
|
373
|
+
[self fireEvent:@"" event:@"on.rewardedInt.loaded" withData:nil]; if (auto_Show){ if (self.rewardedInterstitialAd && [self.rewardedInterstitialAd canPresentFromRootViewController:self.viewController error:nil]) { [self.rewardedInterstitialAd presentFromRootViewController:self.viewController
|
374
|
+
userDidEarnRewardHandler:^{
|
375
|
+
GADAdReward *reward =
|
376
|
+
self.rewardedInterstitialAd.adReward;
|
377
|
+
[self fireEvent:@"" event:@"on.rewardedInt.userEarnedReward" withData:nil];
|
378
|
+
isAdSkip = 2;
|
379
|
+
NSString *rewardMessage = [NSString stringWithFormat:@"Reward received with "
|
380
|
+
@"currency %@ , amount %ld",
|
381
|
+
reward.type, [reward.amount longValue]];
|
382
|
+
NSLog(@"%@", rewardMessage); }]; } else { [self fireEvent:@"" event:@"on.rewardedInt.failed.show" withData:nil];
|
383
|
+
} } }];
|
437
384
|
}
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
pluginResult = [CDVPluginResult resultWithStatus:
|
453
|
-
|
454
|
-
|
455
|
-
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
456
|
-
}
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
self.
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
NSString *rewardMessage = [NSString stringWithFormat:@"Reward received with "
|
486
|
-
@"currency %@ , amount %ld",
|
487
|
-
reward.type, [reward.amount longValue]];
|
488
|
-
NSLog(@"%@", rewardMessage);
|
489
|
-
}];
|
490
|
-
} else {
|
491
|
-
[self fireEvent:@"" event:@"on.rewardedInt.failed.show" withData:nil];
|
385
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
386
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
387
|
+
}-(void)showRewardedInterstitialAd:(CDVInvokedUrlCommand *)command {
|
388
|
+
CDVPluginResult *pluginResult;
|
389
|
+
NSString *callbackId = command.callbackId;
|
390
|
+
if (self.rewardedInterstitialAd && [self.rewardedInterstitialAd canPresentFromRootViewController:self.viewController error:nil]) { [self.rewardedInterstitialAd presentFromRootViewController:self.viewController
|
391
|
+
userDidEarnRewardHandler:^{
|
392
|
+
GADAdReward *reward =
|
393
|
+
self.rewardedInterstitialAd.adReward;
|
394
|
+
[self fireEvent:@"" event:@"on.rewardedInt.userEarnedReward" withData:nil];
|
395
|
+
isAdSkip = 2;
|
396
|
+
NSString *rewardMessage = [NSString stringWithFormat:@"Reward received with "
|
397
|
+
@"currency %@ , amount %ld",
|
398
|
+
reward.type, [reward.amount longValue]];
|
399
|
+
NSLog(@"%@", rewardMessage); }]; pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; } else {
|
400
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
|
401
|
+
[self fireEvent:@"" event:@"on.rewardedInt.failed.show" withData:nil];
|
402
|
+
} [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
403
|
+
}- (void)loadRewardedAd:(CDVInvokedUrlCommand*)command { CDVPluginResult *pluginResult;
|
404
|
+
NSString *callbackId = command.callbackId;
|
405
|
+
NSString* adUnitId = [command.arguments objectAtIndex:0];
|
406
|
+
BOOL autoShow = [[command argumentAtIndex:1] boolValue];
|
407
|
+
auto_Show = autoShow;
|
408
|
+
adFormat = 3;
|
409
|
+
if (adFormat == 3){
|
410
|
+
GADRequest *request = [GADRequest request];
|
411
|
+
[GADRewardedAd
|
412
|
+
loadWithAdUnitID:adUnitId
|
413
|
+
request:request
|
414
|
+
completionHandler:^(GADRewardedAd *ad, NSError *error) {
|
415
|
+
if (error) {
|
416
|
+
NSLog(@"Rewarded ad failed to load with error: %@", [error localizedDescription]);
|
417
|
+
return;
|
418
|
+
}
|
419
|
+
self.rewardedAd = ad;
|
420
|
+
NSLog(@"Rewarded ad loaded.");
|
421
|
+
isAdSkip = 0;
|
422
|
+
self.rewardedAd.fullScreenContentDelegate = self;
|
423
|
+
[self fireEvent:@"" event:@"on.rewarded.loaded" withData:nil]; if (auto_Show){ if (self.rewardedAd && [self.rewardedAd canPresentFromRootViewController:self.viewController error:nil]) { [self.rewardedAd presentFromRootViewController:self.viewController
|
424
|
+
userDidEarnRewardHandler:^{
|
425
|
+
GADAdReward *reward =
|
426
|
+
self.rewardedAd.adReward;
|
427
|
+
[self fireEvent:@"" event:@"on.reward.userEarnedReward" withData:nil];
|
428
|
+
isAdSkip = 2;
|
429
|
+
NSString *rewardMessage = [NSString stringWithFormat:@"Reward received with currency %@ , amount %lf", reward.type, [reward.amount doubleValue]];
|
430
|
+
NSLog(@"%@", rewardMessage); }]; } else { [self fireEvent:@"" event:@"on.rewarded.failed.show" withData:nil];
|
431
|
+
} } }];
|
492
432
|
}
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
|
516
|
-
[self fireEvent:@"" event:@"on.rewardedInt.failed.show" withData:nil];
|
517
|
-
}
|
518
|
-
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
519
|
-
}
|
520
|
-
- (void)loadRewardedAd:(CDVInvokedUrlCommand*)command {
|
521
|
-
CDVPluginResult *pluginResult;
|
522
|
-
NSString *callbackId = command.callbackId;
|
523
|
-
NSString* adUnitId = [command.arguments objectAtIndex:0];
|
524
|
-
BOOL autoShow = [[command argumentAtIndex:1] boolValue];
|
525
|
-
auto_Show = autoShow;
|
526
|
-
adFormat = 3;
|
527
|
-
if (adFormat == 3){
|
528
|
-
GADRequest *request = [GADRequest request];
|
529
|
-
[GADRewardedAd
|
530
|
-
loadWithAdUnitID:adUnitId
|
531
|
-
request:request
|
532
|
-
completionHandler:^(GADRewardedAd *ad, NSError *error) {
|
533
|
-
if (error) {
|
534
|
-
NSLog(@"Rewarded ad failed to load with error: %@", [error localizedDescription]);
|
535
|
-
return;
|
536
|
-
}
|
537
|
-
self.rewardedAd = ad;
|
538
|
-
NSLog(@"Rewarded ad loaded.");
|
539
|
-
self.rewardedAd.fullScreenContentDelegate = self;
|
540
|
-
[self fireEvent:@"" event:@"on.rewarded.loaded" withData:nil];
|
541
|
-
if (auto_Show){
|
542
|
-
if (self.rewardedAd && [self.rewardedAd canPresentFromRootViewController:self.viewController error:nil]) {
|
543
|
-
[self.rewardedAd presentFromRootViewController:self.viewController
|
544
|
-
userDidEarnRewardHandler:^{
|
545
|
-
GADAdReward *reward =
|
546
|
-
self.rewardedAd.adReward;
|
547
|
-
[self fireEvent:@"" event:@"on.reward.userEarnedReward" withData:nil];
|
548
|
-
NSString *rewardMessage = [NSString stringWithFormat:@"Reward received with currency %@ , amount %lf", reward.type, [reward.amount doubleValue]];
|
549
|
-
NSLog(@"%@", rewardMessage);
|
550
|
-
}];
|
433
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
434
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
435
|
+
}-(void)showRewardedAd:(CDVInvokedUrlCommand *)command {
|
436
|
+
CDVPluginResult *pluginResult;
|
437
|
+
NSString *callbackId = command.callbackId;
|
438
|
+
if (self.rewardedAd && [self.rewardedAd canPresentFromRootViewController:self.viewController error:nil]) { [self.rewardedAd presentFromRootViewController:self.viewController
|
439
|
+
userDidEarnRewardHandler:^{
|
440
|
+
GADAdReward *reward =
|
441
|
+
self.rewardedAd.adReward;
|
442
|
+
[self fireEvent:@"" event:@"on.reward.userEarnedReward" withData:nil];
|
443
|
+
isAdSkip = 2;
|
444
|
+
NSString *rewardMessage = [NSString stringWithFormat:@"Reward received with currency %@ , amount %lf", reward.type, [reward.amount doubleValue]];
|
445
|
+
NSLog(@"%@", rewardMessage); }]; pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; } else {
|
446
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
|
447
|
+
[self fireEvent:@"" event:@"on.rewarded.failed.show" withData:nil];
|
448
|
+
} [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
449
|
+
}- (void) fireEvent:(NSString *)obj event:(NSString *)eventName withData:(NSString *)jsonStr {
|
450
|
+
NSString* js;
|
451
|
+
if(obj && [obj isEqualToString:@"window"]) {
|
452
|
+
js = [NSString stringWithFormat:@"var evt=document.createEvent(\"UIEvents\");evt.initUIEvent(\"%@\",true,false,window,0);window.dispatchEvent(evt);", eventName];
|
453
|
+
} else if(jsonStr && [jsonStr length]>0) {
|
454
|
+
js = [NSString stringWithFormat:@"javascript:cordova.fireDocumentEvent('%@',%@);", eventName, jsonStr];
|
551
455
|
} else {
|
552
|
-
[
|
456
|
+
js = [NSString stringWithFormat:@"javascript:cordova.fireDocumentEvent('%@');", eventName];
|
553
457
|
}
|
458
|
+
[self.commandDelegate evalJs:js];
|
554
459
|
}
|
555
|
-
}];
|
556
|
-
}
|
557
|
-
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
558
|
-
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
559
|
-
}
|
560
|
-
-(void)showRewardedAd:(CDVInvokedUrlCommand *)command {
|
561
|
-
CDVPluginResult *pluginResult;
|
562
|
-
NSString *callbackId = command.callbackId;
|
563
|
-
if (self.rewardedAd && [self.rewardedAd canPresentFromRootViewController:self.viewController error:nil]) {
|
564
|
-
[self.rewardedAd presentFromRootViewController:self.viewController
|
565
|
-
userDidEarnRewardHandler:^{
|
566
|
-
GADAdReward *reward =
|
567
|
-
self.rewardedAd.adReward;
|
568
|
-
[self fireEvent:@"" event:@"on.reward.userEarnedReward" withData:nil];
|
569
|
-
NSString *rewardMessage = [NSString stringWithFormat:@"Reward received with currency %@ , amount %lf", reward.type, [reward.amount doubleValue]];
|
570
|
-
NSLog(@"%@", rewardMessage);
|
571
|
-
}];
|
572
|
-
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
573
|
-
} else {
|
574
|
-
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
|
575
|
-
[self fireEvent:@"" event:@"on.rewarded.failed.show" withData:nil];
|
576
|
-
}
|
577
|
-
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
578
|
-
}
|
579
460
|
#pragma mark GADBannerViewDelegate implementation
|
580
|
-
-
|
461
|
+
-(void)bannerViewDidReceiveAd:(GADBannerView *)bannerView {
|
581
462
|
[self fireEvent:@"" event:@"on.banner.load" withData:nil];
|
582
463
|
NSLog(@"bannerViewDidReceiveAd");
|
583
464
|
if (auto_Show){
|
584
465
|
if(self.bannerView) {
|
585
466
|
[self addBannerViewToView:command];
|
586
|
-
self.bannerView.hidden = NO;
|
467
|
+
self.bannerView.hidden = NO;
|
587
468
|
}
|
588
|
-
} else {
|
589
|
-
|
469
|
+
} else { [self fireEvent:@"" event:@"on.banner.failed.show" withData:nil];
|
470
|
+
}}- (void)bannerView:(GADBannerView *)bannerView didFailToReceiveAdWithError:(NSError *)error {
|
471
|
+
[self fireEvent:@"" event:@"on.banner.failed.load" withData:nil];
|
472
|
+
NSLog(@"bannerView:didFailToReceiveAdWithError: %@", [error localizedDescription]);
|
473
|
+
}- (void)bannerViewDidRecordImpression:(GADBannerView *)bannerView {
|
474
|
+
[self fireEvent:@"" event:@"on.banner.impression" withData:nil];
|
475
|
+
NSLog(@"bannerViewDidRecordImpression");
|
476
|
+
}- (void)bannerViewWillPresentScreen:(GADBannerView *)bannerView {
|
477
|
+
[self fireEvent:@"" event:@"on.banner.open" withData:nil];
|
478
|
+
NSLog(@"bannerViewWillPresentScreen");
|
479
|
+
}- (void)bannerViewWillDismissScreen:(GADBannerView *)bannerView {
|
480
|
+
[self fireEvent:@"" event:@"on.banner.close" withData:nil];
|
481
|
+
NSLog(@"bannerViewWillDismissScreen");
|
482
|
+
}- (void)bannerViewDidDismissScreen:(GADBannerView *)bannerView {
|
483
|
+
[self fireEvent:@"" event:@"on.banner.did.dismiss" withData:nil];
|
484
|
+
NSLog(@"bannerViewDidDismissScreen");
|
590
485
|
}
|
591
|
-
}
|
592
|
-
- (void)bannerView:(GADBannerView *)bannerView didFailToReceiveAdWithError:(NSError *)error {
|
593
|
-
[self fireEvent:@"" event:@"on.banner.failed.load" withData:nil];
|
594
|
-
NSLog(@"bannerView:didFailToReceiveAdWithError: %@", [error localizedDescription]);
|
595
|
-
}
|
596
|
-
- (void)bannerViewDidRecordImpression:(GADBannerView *)bannerView {
|
597
|
-
[self fireEvent:@"" event:@"on.banner.impression" withData:nil];
|
598
|
-
NSLog(@"bannerViewDidRecordImpression");
|
599
|
-
}
|
600
|
-
- (void)bannerViewWillPresentScreen:(GADBannerView *)bannerView {
|
601
|
-
[self fireEvent:@"" event:@"on.banner.open" withData:nil];
|
602
|
-
NSLog(@"bannerViewWillPresentScreen");
|
603
|
-
}
|
604
|
-
- (void)bannerViewWillDismissScreen:(GADBannerView *)bannerView {
|
605
|
-
[self fireEvent:@"" event:@"on.banner.close" withData:nil];
|
606
|
-
NSLog(@"bannerViewWillDismissScreen");
|
607
|
-
}
|
608
|
-
- (void)bannerViewDidDismissScreen:(GADBannerView *)bannerView {
|
609
|
-
[self fireEvent:@"" event:@"on.banner.did.dismiss" withData:nil];
|
610
|
-
NSLog(@"bannerViewDidDismissScreen");
|
611
|
-
}
|
612
486
|
#pragma GADFullScreeContentDelegate implementation
|
613
|
-
- (void)adWillPresentFullScreenContent:(id)ad {
|
614
|
-
if (adFormat ==
|
615
|
-
[self fireEvent:@"" event:@"on.appOpenAd.show" withData:nil];
|
616
|
-
NSLog(@"Ad will present full screen content App Open Ad.");
|
617
|
-
} else if (adFormat == 2){
|
618
|
-
[self fireEvent:@"" event:@"on.interstitial.show" withData:nil];
|
487
|
+
- (void)adWillPresentFullScreenContent:(id)ad { if (adFormat == 1){ [self fireEvent:@"" event:@"on.appOpenAd.show" withData:nil];
|
488
|
+
NSLog(@"Ad will present full screen content App Open Ad."); } else if (adFormat == 2){ [self fireEvent:@"" event:@"on.interstitial.show" withData:nil];
|
619
489
|
[self fireEvent:@"" event:@"onPresentAd" withData:nil];
|
620
|
-
NSLog(@"Ad will present full screen content interstitial.");
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
}
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
[self fireEvent:@"" event:@"on.
|
632
|
-
|
633
|
-
} else if (adFormat == 2){
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
} else if (adFormat == 4) {
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
if (adFormat == 1){
|
646
|
-
[self fireEvent:@"" event:@"on.appOpenAd.dismissed" withData:nil];
|
647
|
-
NSLog(@"Ad did dismiss full screen content App Open Ad.");
|
648
|
-
} else if (adFormat == 2){
|
649
|
-
[self fireEvent:@"" event:@"on.interstitial.dismissed" withData:nil];
|
650
|
-
NSLog(@"Ad did dismiss full screen content interstitial.");
|
651
|
-
} else if (adFormat == 3) {
|
652
|
-
[self fireEvent:@"" event:@"on.rewarded.dismissed" withData:nil];
|
653
|
-
NSLog(@"Ad did dismiss full screen content rewarded.");
|
654
|
-
} else if (adFormat == 4) {
|
655
|
-
[self fireEvent:@"" event:@"on.rewardedInt.dismissed" withData:nil];
|
656
|
-
NSLog(@"Ad did dismiss full screen content interstitial rewarded.");
|
657
|
-
}
|
658
|
-
}
|
490
|
+
NSLog(@"Ad will present full screen content interstitial."); } else if (adFormat == 3) { [self fireEvent:@"" event:@"on.rewarded.show" withData:nil];
|
491
|
+
isAdSkip = 1;
|
492
|
+
NSLog(@"Ad will present full screen content rewarded."); } else if (adFormat == 4) {
|
493
|
+
isAdSkip = 1;
|
494
|
+
[self fireEvent:@"" event:@"on.rewardedInt.showed" withData:nil];
|
495
|
+
NSLog(@"Ad will present full screen content interstitial rewarded.");
|
496
|
+
}}- (void)ad:(id)ad didFailToPresentFullScreenContentWithError:(NSError *)error { if (adFormat == 1){ [self fireEvent:@"" event:@"on.appOpenAd.failed.loaded" withData:nil];
|
497
|
+
NSLog(@"Ad failed to present full screen content with error App Open Ad %@.", [error localizedDescription]); } else if (adFormat == 2){
|
498
|
+
[self fireEvent:@"" event:@"on.interstitial.failed.load" withData:nil];
|
499
|
+
NSLog(@"Ad failed to present full screen content with error interstitial %@.", [error localizedDescription]);
|
500
|
+
} else if (adFormat == 3) { [self fireEvent:@"" event:@"on.rewarded.failed.load" withData:nil];
|
501
|
+
NSLog(@"Ad failed to present full screen content with error rewarded %@.", [error localizedDescription]); } else if (adFormat == 4) { [self fireEvent:@"" event:@"on.rewardedInt.failed.load" withData:nil];
|
502
|
+
NSLog(@"Ad failed to present full screen content with error interstitial rewarded %@.", [error localizedDescription]); }}- (void)adDidDismissFullScreenContent:(id)ad { if (adFormat == 1){ [self fireEvent:@"" event:@"on.appOpenAd.dismissed" withData:nil];
|
503
|
+
NSLog(@"Ad did dismiss full screen content App Open Ad."); } else if (adFormat == 2){
|
504
|
+
[self fireEvent:@"" event:@"on.interstitial.dismissed" withData:nil];
|
505
|
+
NSLog(@"Ad did dismiss full screen content interstitial.");
|
506
|
+
} else if (adFormat == 3) { [self fireEvent:@"" event:@"on.rewarded.dismissed" withData:nil]; if (isAdSkip != 2) {
|
507
|
+
[self fireEvent:@"" event:@"on.rewarded.ad.skip" withData:nil];
|
508
|
+
}
|
509
|
+
NSLog(@"Ad did dismiss full screen content rewarded."); } else if (adFormat == 4) {
|
510
|
+
if (isAdSkip != 2) {
|
511
|
+
[self fireEvent:@"" event:@"on.rewardedInt.ad.skip" withData:nil];
|
512
|
+
}
|
513
|
+
[self fireEvent:@"" event:@"on.rewardedInt.dismissed" withData:nil];
|
514
|
+
NSLog(@"Ad did dismiss full screen content interstitial rewarded."); }}
|
659
515
|
#pragma mark Cleanup
|
660
516
|
- (void)dealloc {
|
661
517
|
self.appOpenAd = nil;
|