forked from flutter/packages
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinteractive_media_ads.g.dart
More file actions
4270 lines (4070 loc) · 172 KB
/
interactive_media_ads.g.dart
File metadata and controls
4270 lines (4070 loc) · 172 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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
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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
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
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
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
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Autogenerated from Pigeon (v22.7.2), do not edit directly.
// See also: https://pub.dev/packages/pigeon
// ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import, no_leading_underscores_for_local_identifiers
import 'dart:async';
import 'dart:typed_data' show Float64List, Int32List, Int64List, Uint8List;
import 'package:flutter/foundation.dart' show ReadBuffer, WriteBuffer, immutable, protected;
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart' show WidgetsFlutterBinding;
PlatformException _createConnectionError(String channelName) {
return PlatformException(
code: 'channel-error',
message: 'Unable to establish connection on channel: "$channelName".',
);
}
List<Object?> wrapResponse({Object? result, PlatformException? error, bool empty = false}) {
if (empty) {
return <Object?>[];
}
if (error == null) {
return <Object?>[result];
}
return <Object?>[error.code, error.message, error.details];
}
/// An immutable object that serves as the base class for all ProxyApis and
/// can provide functional copies of itself.
///
/// All implementers are expected to be [immutable] as defined by the annotation
/// and override [pigeon_copy] returning an instance of itself.
@immutable
abstract class PigeonInternalProxyApiBaseClass {
/// Construct a [PigeonInternalProxyApiBaseClass].
PigeonInternalProxyApiBaseClass({
this.pigeon_binaryMessenger,
PigeonInstanceManager? pigeon_instanceManager,
}) : pigeon_instanceManager =
pigeon_instanceManager ?? PigeonInstanceManager.instance;
/// Sends and receives binary data across the Flutter platform barrier.
///
/// If it is null, the default BinaryMessenger will be used, which routes to
/// the host platform.
@protected
final BinaryMessenger? pigeon_binaryMessenger;
/// Maintains instances stored to communicate with native language objects.
final PigeonInstanceManager pigeon_instanceManager;
/// Instantiates and returns a functionally identical object to oneself.
///
/// Outside of tests, this method should only ever be called by
/// [PigeonInstanceManager].
///
/// Subclasses should always override their parent's implementation of this
/// method.
@protected
PigeonInternalProxyApiBaseClass pigeon_copy();
}
/// Maintains instances used to communicate with the native objects they
/// represent.
///
/// Added instances are stored as weak references and their copies are stored
/// as strong references to maintain access to their variables and callback
/// methods. Both are stored with the same identifier.
///
/// When a weak referenced instance becomes inaccessible,
/// [onWeakReferenceRemoved] is called with its associated identifier.
///
/// If an instance is retrieved and has the possibility to be used,
/// (e.g. calling [getInstanceWithWeakReference]) a copy of the strong reference
/// is added as a weak reference with the same identifier. This prevents a
/// scenario where the weak referenced instance was released and then later
/// returned by the host platform.
class PigeonInstanceManager {
/// Constructs a [PigeonInstanceManager].
PigeonInstanceManager({required void Function(int) onWeakReferenceRemoved}) {
this.onWeakReferenceRemoved = (int identifier) {
_weakInstances.remove(identifier);
onWeakReferenceRemoved(identifier);
};
_finalizer = Finalizer<int>(this.onWeakReferenceRemoved);
}
// Identifiers are locked to a specific range to avoid collisions with objects
// created simultaneously by the host platform.
// Host uses identifiers >= 2^16 and Dart is expected to use values n where,
// 0 <= n < 2^16.
static const int _maxDartCreatedIdentifier = 65536;
/// The default [PigeonInstanceManager] used by ProxyApis.
///
/// On creation, this manager makes a call to clear the native
/// InstanceManager. This is to prevent identifier conflicts after a host
/// restart.
static final PigeonInstanceManager instance = _initInstance();
// Expando is used because it doesn't prevent its keys from becoming
// inaccessible. This allows the manager to efficiently retrieve an identifier
// of an instance without holding a strong reference to that instance.
//
// It also doesn't use `==` to search for identifiers, which would lead to an
// infinite loop when comparing an object to its copy. (i.e. which was caused
// by calling instanceManager.getIdentifier() inside of `==` while this was a
// HashMap).
final Expando<int> _identifiers = Expando<int>();
final Map<int, WeakReference<PigeonInternalProxyApiBaseClass>> _weakInstances =
<int, WeakReference<PigeonInternalProxyApiBaseClass>>{};
final Map<int, PigeonInternalProxyApiBaseClass> _strongInstances = <int, PigeonInternalProxyApiBaseClass>{};
late final Finalizer<int> _finalizer;
int _nextIdentifier = 0;
/// Called when a weak referenced instance is removed by [removeWeakReference]
/// or becomes inaccessible.
late final void Function(int) onWeakReferenceRemoved;
static PigeonInstanceManager _initInstance() {
WidgetsFlutterBinding.ensureInitialized();
final _PigeonInternalInstanceManagerApi api = _PigeonInternalInstanceManagerApi();
// Clears the native `PigeonInstanceManager` on the initial use of the Dart one.
api.clear();
final PigeonInstanceManager instanceManager = PigeonInstanceManager(
onWeakReferenceRemoved: (int identifier) {
api.removeStrongReference(identifier);
},
);
_PigeonInternalInstanceManagerApi.setUpMessageHandlers(instanceManager: instanceManager);
IMAAdDisplayContainer.pigeon_setUpMessageHandlers(pigeon_instanceManager: instanceManager);
UIView.pigeon_setUpMessageHandlers(pigeon_instanceManager: instanceManager);
UIViewController.pigeon_setUpMessageHandlers(pigeon_instanceManager: instanceManager);
IMAContentPlayhead.pigeon_setUpMessageHandlers(pigeon_instanceManager: instanceManager);
IMAAdsLoader.pigeon_setUpMessageHandlers(pigeon_instanceManager: instanceManager);
IMASettings.pigeon_setUpMessageHandlers(pigeon_instanceManager: instanceManager);
IMAAdsRequest.pigeon_setUpMessageHandlers(pigeon_instanceManager: instanceManager);
IMAAdsLoaderDelegate.pigeon_setUpMessageHandlers(pigeon_instanceManager: instanceManager);
IMAAdsLoadedData.pigeon_setUpMessageHandlers(pigeon_instanceManager: instanceManager);
IMAAdLoadingErrorData.pigeon_setUpMessageHandlers(pigeon_instanceManager: instanceManager);
IMAAdError.pigeon_setUpMessageHandlers(pigeon_instanceManager: instanceManager);
IMAAdsManager.pigeon_setUpMessageHandlers(pigeon_instanceManager: instanceManager);
IMAAdsManagerDelegate.pigeon_setUpMessageHandlers(pigeon_instanceManager: instanceManager);
IMAAdEvent.pigeon_setUpMessageHandlers(pigeon_instanceManager: instanceManager);
IMAAdsRenderingSettings.pigeon_setUpMessageHandlers(pigeon_instanceManager: instanceManager);
NSObject.pigeon_setUpMessageHandlers(pigeon_instanceManager: instanceManager);
IMAFriendlyObstruction.pigeon_setUpMessageHandlers(pigeon_instanceManager: instanceManager);
IMACompanionAd.pigeon_setUpMessageHandlers(pigeon_instanceManager: instanceManager);
IMACompanionAdSlot.pigeon_setUpMessageHandlers(pigeon_instanceManager: instanceManager);
IMACompanionDelegate.pigeon_setUpMessageHandlers(pigeon_instanceManager: instanceManager);
IMAAdPodInfo.pigeon_setUpMessageHandlers(pigeon_instanceManager: instanceManager);
return instanceManager;
}
/// Adds a new instance that was instantiated by Dart.
///
/// In other words, Dart wants to add a new instance that will represent
/// an object that will be instantiated on the host platform.
///
/// Throws assertion error if the instance has already been added.
///
/// Returns the randomly generated id of the [instance] added.
int addDartCreatedInstance(PigeonInternalProxyApiBaseClass instance) {
final int identifier = _nextUniqueIdentifier();
_addInstanceWithIdentifier(instance, identifier);
return identifier;
}
/// Removes the instance, if present, and call [onWeakReferenceRemoved] with
/// its identifier.
///
/// Returns the identifier associated with the removed instance. Otherwise,
/// `null` if the instance was not found in this manager.
///
/// This does not remove the strong referenced instance associated with
/// [instance]. This can be done with [remove].
int? removeWeakReference(PigeonInternalProxyApiBaseClass instance) {
final int? identifier = getIdentifier(instance);
if (identifier == null) {
return null;
}
_identifiers[instance] = null;
_finalizer.detach(instance);
onWeakReferenceRemoved(identifier);
return identifier;
}
/// Removes [identifier] and its associated strongly referenced instance, if
/// present, from the manager.
///
/// Returns the strong referenced instance associated with [identifier] before
/// it was removed. Returns `null` if [identifier] was not associated with
/// any strong reference.
///
/// This does not remove the weak referenced instance associated with
/// [identifier]. This can be done with [removeWeakReference].
T? remove<T extends PigeonInternalProxyApiBaseClass>(int identifier) {
return _strongInstances.remove(identifier) as T?;
}
/// Retrieves the instance associated with identifier.
///
/// The value returned is chosen from the following order:
///
/// 1. A weakly referenced instance associated with identifier.
/// 2. If the only instance associated with identifier is a strongly
/// referenced instance, a copy of the instance is added as a weak reference
/// with the same identifier. Returning the newly created copy.
/// 3. If no instance is associated with identifier, returns null.
///
/// This method also expects the host `InstanceManager` to have a strong
/// reference to the instance the identifier is associated with.
T? getInstanceWithWeakReference<T extends PigeonInternalProxyApiBaseClass>(int identifier) {
final PigeonInternalProxyApiBaseClass? weakInstance = _weakInstances[identifier]?.target;
if (weakInstance == null) {
final PigeonInternalProxyApiBaseClass? strongInstance = _strongInstances[identifier];
if (strongInstance != null) {
final PigeonInternalProxyApiBaseClass copy = strongInstance.pigeon_copy();
_identifiers[copy] = identifier;
_weakInstances[identifier] = WeakReference<PigeonInternalProxyApiBaseClass>(copy);
_finalizer.attach(copy, identifier, detach: copy);
return copy as T;
}
return strongInstance as T?;
}
return weakInstance as T;
}
/// Retrieves the identifier associated with instance.
int? getIdentifier(PigeonInternalProxyApiBaseClass instance) {
return _identifiers[instance];
}
/// Adds a new instance that was instantiated by the host platform.
///
/// In other words, the host platform wants to add a new instance that
/// represents an object on the host platform. Stored with [identifier].
///
/// Throws assertion error if the instance or its identifier has already been
/// added.
///
/// Returns unique identifier of the [instance] added.
void addHostCreatedInstance(PigeonInternalProxyApiBaseClass instance, int identifier) {
_addInstanceWithIdentifier(instance, identifier);
}
void _addInstanceWithIdentifier(PigeonInternalProxyApiBaseClass instance, int identifier) {
assert(!containsIdentifier(identifier));
assert(getIdentifier(instance) == null);
assert(identifier >= 0);
_identifiers[instance] = identifier;
_weakInstances[identifier] = WeakReference<PigeonInternalProxyApiBaseClass>(instance);
_finalizer.attach(instance, identifier, detach: instance);
final PigeonInternalProxyApiBaseClass copy = instance.pigeon_copy();
_identifiers[copy] = identifier;
_strongInstances[identifier] = copy;
}
/// Whether this manager contains the given [identifier].
bool containsIdentifier(int identifier) {
return _weakInstances.containsKey(identifier) ||
_strongInstances.containsKey(identifier);
}
int _nextUniqueIdentifier() {
late int identifier;
do {
identifier = _nextIdentifier;
_nextIdentifier = (_nextIdentifier + 1) % _maxDartCreatedIdentifier;
} while (containsIdentifier(identifier));
return identifier;
}
}
/// Generated API for managing the Dart and native `PigeonInstanceManager`s.
class _PigeonInternalInstanceManagerApi {
/// Constructor for [_PigeonInternalInstanceManagerApi].
_PigeonInternalInstanceManagerApi({BinaryMessenger? binaryMessenger})
: pigeonVar_binaryMessenger = binaryMessenger;
final BinaryMessenger? pigeonVar_binaryMessenger;
static const MessageCodec<Object?> pigeonChannelCodec = _PigeonCodec();
static void setUpMessageHandlers({
bool pigeon_clearHandlers = false,
BinaryMessenger? binaryMessenger,
PigeonInstanceManager? instanceManager,
}) {
{
final BasicMessageChannel<
Object?> pigeonVar_channel = BasicMessageChannel<
Object?>(
'dev.flutter.pigeon.interactive_media_ads.PigeonInternalInstanceManager.removeStrongReference',
pigeonChannelCodec,
binaryMessenger: binaryMessenger);
if (pigeon_clearHandlers) {
pigeonVar_channel.setMessageHandler(null);
} else {
pigeonVar_channel.setMessageHandler((Object? message) async {
assert(message != null,
'Argument for dev.flutter.pigeon.interactive_media_ads.PigeonInternalInstanceManager.removeStrongReference was null.');
final List<Object?> args = (message as List<Object?>?)!;
final int? arg_identifier = (args[0] as int?);
assert(arg_identifier != null,
'Argument for dev.flutter.pigeon.interactive_media_ads.PigeonInternalInstanceManager.removeStrongReference was null, expected non-null int.');
try {
(instanceManager ?? PigeonInstanceManager.instance)
.remove(arg_identifier!);
return wrapResponse(empty: true);
} on PlatformException catch (e) {
return wrapResponse(error: e);
} catch (e) {
return wrapResponse(
error: PlatformException(code: 'error', message: e.toString()));
}
});
}
}
}
Future<void> removeStrongReference(int identifier) async {
const String pigeonVar_channelName =
'dev.flutter.pigeon.interactive_media_ads.PigeonInternalInstanceManager.removeStrongReference';
final BasicMessageChannel<Object?> pigeonVar_channel =
BasicMessageChannel<Object?>(
pigeonVar_channelName,
pigeonChannelCodec,
binaryMessenger: pigeonVar_binaryMessenger,
);
final List<Object?>? pigeonVar_replyList =
await pigeonVar_channel.send(<Object?>[identifier]) as List<Object?>?;
if (pigeonVar_replyList == null) {
throw _createConnectionError(pigeonVar_channelName);
} else if (pigeonVar_replyList.length > 1) {
throw PlatformException(
code: pigeonVar_replyList[0]! as String,
message: pigeonVar_replyList[1] as String?,
details: pigeonVar_replyList[2],
);
} else {
return;
}
}
/// Clear the native `PigeonInstanceManager`.
///
/// This is typically called after a hot restart.
Future<void> clear() async {
const String pigeonVar_channelName =
'dev.flutter.pigeon.interactive_media_ads.PigeonInternalInstanceManager.clear';
final BasicMessageChannel<Object?> pigeonVar_channel =
BasicMessageChannel<Object?>(
pigeonVar_channelName,
pigeonChannelCodec,
binaryMessenger: pigeonVar_binaryMessenger,
);
final List<Object?>? pigeonVar_replyList =
await pigeonVar_channel.send(null) as List<Object?>?;
if (pigeonVar_replyList == null) {
throw _createConnectionError(pigeonVar_channelName);
} else if (pigeonVar_replyList.length > 1) {
throw PlatformException(
code: pigeonVar_replyList[0]! as String,
message: pigeonVar_replyList[1] as String?,
details: pigeonVar_replyList[2],
);
} else {
return;
}
}
}
class _PigeonInternalProxyApiBaseCodec extends _PigeonCodec {
const _PigeonInternalProxyApiBaseCodec(this.instanceManager);
final PigeonInstanceManager instanceManager;
@override
void writeValue(WriteBuffer buffer, Object? value) {
if (value is PigeonInternalProxyApiBaseClass) {
buffer.putUint8(128);
writeValue(buffer, instanceManager.getIdentifier(value));
} else {
super.writeValue(buffer, value);
}
}
@override
Object? readValueOfType(int type, ReadBuffer buffer) {
switch (type) {
case 128:
return instanceManager
.getInstanceWithWeakReference(readValue(buffer)! as int);
default:
return super.readValueOfType(type, buffer);
}
}
}
/// Possible error types while loading or playing ads.
///
/// See https://developers.google.com/interactive-media-ads/docs/sdks/ios/client-side/reference/Enums/IMAErrorType.html.
enum AdErrorType {
/// An error occurred while loading the ads.
loadingFailed,
/// An error occurred while playing the ads.
adPlayingFailed,
/// An unexpected error occurred while loading or playing the ads.
///
/// This may mean that the SDK wasn’t loaded properly or the wrapper doesn't
/// recognize this value.
unknown,
}
/// Possible error codes raised while loading or playing ads.
///
/// See https://developers.google.com/interactive-media-ads/docs/sdks/ios/client-side/reference/Enums/IMAErrorCode.html.
enum AdErrorCode {
/// The ad slot is not visible on the page.
adslotNotVisible,
/// Generic invalid usage of the API.
apiError,
/// A companion ad failed to load or render.
companionAdLoadingFailed,
/// Content playhead was not passed in, but list of ads has been returned from
/// the server.
contentPlayheadMissing,
/// There was an error loading the ad.
failedLoadingAd,
/// There was a problem requesting ads from the server.
failedToRequestAds,
/// Invalid arguments were provided to SDK methods.
invalidArguments,
/// The version of the runtime is too old.
osRuntimeTooOld,
/// Ads list response was malformed.
playlistMalformedResponse,
/// Listener for at least one of the required vast events was not added.
requiredListenersNotAdded,
/// There was an error initializing the stream.
streamInitializationFailed,
/// An unexpected error occurred and the cause is not known.
unknownError,
/// No assets were found in the VAST ad response.
vastAssetNotFound,
/// A VAST response containing a single `<VAST>` tag with no child tags.
vastEmptyResponse,
/// At least one VAST wrapper loaded and a subsequent wrapper or inline ad
/// load has resulted in a 404 response code.
vastInvalidUrl,
/// Assets were found in the VAST ad response for a linear ad, but none of
/// them matched the video player's capabilities.
vastLinearAssetMismatch,
/// The VAST URI provided, or a VAST URI provided in a subsequent Wrapper
/// element, was either unavailable or reached a timeout, as defined by the
/// video player.
vastLoadTimeout,
/// The ad response was not recognized as a valid VAST ad.
vastMalformedResponse,
/// Failed to load media assets from a VAST response.
vastMediaLoadTimeout,
/// The maximum number of VAST wrapper redirects has been reached.
vastTooManyRedirects,
/// Trafficking error.
///
/// Video player received an ad type that it was not expecting and/or cannot
/// display.
vastTraffickingError,
/// Another VideoAdsManager is still using the video.
videoElementUsed,
/// A video element was not specified where it was required.
videoElementRequired,
/// There was an error playing the video ad.
videoPlayError,
}
/// Different event types sent by the IMAAdsManager to its delegate.
///
/// See https://developers.google.com/interactive-media-ads/docs/sdks/ios/client-side/reference/Enums/IMAAdEventType.html.
enum AdEventType {
/// Fired the first time each ad break ends.
adBreakEnded,
/// Fired when an ad break will not play back any ads.
adBreakFetchError,
/// Fired when an ad break is ready.
adBreakReady,
/// Fired first time each ad break begins playback.
adBreakStarted,
/// Fired every time the stream switches from advertising or slate to content.
adPeriodEnded,
/// Fired every time the stream switches from content to advertising or slate.
adPeriodStarted,
/// All valid ads managed by the ads manager have completed or the ad response
/// did not return any valid ads.
allAdsCompleted,
/// Fired when an ad is clicked.
clicked,
/// Single ad has finished.
completed,
/// Cuepoints changed for VOD stream (only used for dynamic ad insertion).
cuepointsChanged,
/// First quartile of a linear ad was reached.
firstQuartile,
/// The user has closed the icon fallback image dialog.
iconFallbackImageClosed,
/// The user has tapped an ad icon.
iconTapped,
/// An ad was loaded.
loaded,
/// A log event for the ads being played.
log,
/// Midpoint of a linear ad was reached.
midpoint,
/// Ad paused.
pause,
/// Ad resumed.
resume,
/// Fired when an ad was skipped.
skipped,
/// Fired when an ad starts playing.
started,
/// Stream request has loaded (only used for dynamic ad insertion).
streamLoaded,
/// Stream has started playing (only used for dynamic ad insertion).
streamStarted,
/// Ad tapped.
tapped,
/// Third quartile of a linear ad was reached..
thirdQuartile,
/// The event type is not recognized by this wrapper.
unknown,
}
/// The values that can be returned in a change dictionary.
///
/// See https://developer.apple.com/documentation/foundation/nskeyvalueobservingoptions?language=objc.
enum KeyValueObservingOptions {
/// Indicates that the change dictionary should provide the new attribute
/// value, if applicable.
newValue,
/// Indicates that the change dictionary should contain the old attribute
/// value, if applicable.
oldValue,
/// If specified, a notification should be sent to the observer immediately,
/// before the observer registration method even returns.
initialValue,
/// Whether separate notifications should be sent to the observer before and
/// after each change, instead of a single notification after the change.
priorNotification,
}
/// The kinds of changes that can be observed..
///
/// See https://developer.apple.com/documentation/foundation/nskeyvaluechange?language=objc.
enum KeyValueChange {
/// Indicates that the value of the observed key path was set to a new value.
setting,
/// Indicates that an object has been inserted into the to-many relationship
/// that is being observed.
insertion,
/// Indicates that an object has been removed from the to-many relationship
/// that is being observed.
removal,
/// Indicates that an object has been replaced in the to-many relationship
/// that is being observed.
replacement,
}
/// The keys that can appear in the change dictionary..
///
/// See https://developer.apple.com/documentation/foundation/nskeyvaluechangekey?language=objc.
enum KeyValueChangeKey {
/// If the value of the kindKey entry is NSKeyValueChange.insertion,
/// NSKeyValueChange.removal, or NSKeyValueChange.replacement, the value of
/// this key is an NSIndexSet object that contains the indexes of the
/// inserted, removed, or replaced objects.
indexes,
/// An NSNumber object that contains a value corresponding to one of the
/// NSKeyValueChange enums, indicating what sort of change has occurred.
kind,
/// If the value of the kindKey entry is NSKeyValueChange.setting, and new was
/// specified when the observer was registered, the value of this key is the
/// new value for the attribute.
newValue,
/// If the prior option was specified when the observer was registered this
/// notification is sent prior to a change.
notificationIsPrior,
/// If the value of the kindKey entry is NSKeyValueChange.setting, and old was
/// specified when the observer was registered, the value of this key is the
/// value before the attribute was changed.
oldValue,
/// The key is not recognized by this wrapper.
unknown,
}
/// A list of purposes for which an obstruction would be registered as friendly.
///
/// See https://developers.google.com/ad-manager/dynamic-ad-insertion/sdk/ios/reference/Enums/IMAFriendlyObstructionPurpose.html.
enum FriendlyObstructionPurpose {
mediaControls,
closeAd,
notVisible,
other,
/// The purpose type is not recognized by this wrapper.
unknown,
}
/// Different UI elements that can be customized.
///
/// See https://developers.google.com/ad-manager/dynamic-ad-insertion/sdk/ios/reference/Enums/IMAUiElementType.html.
enum UIElementType {
/// Ad attribution UI element.
adAttribution,
/// Ad countdown element.
countdown,
/// The element is not recognized by this wrapper.
unknown,
}
class _PigeonCodec extends StandardMessageCodec {
const _PigeonCodec();
@override
void writeValue(WriteBuffer buffer, Object? value) {
if (value is int) {
buffer.putUint8(4);
buffer.putInt64(value);
} else if (value is AdErrorType) {
buffer.putUint8(129);
writeValue(buffer, value.index);
} else if (value is AdErrorCode) {
buffer.putUint8(130);
writeValue(buffer, value.index);
} else if (value is AdEventType) {
buffer.putUint8(131);
writeValue(buffer, value.index);
} else if (value is KeyValueObservingOptions) {
buffer.putUint8(132);
writeValue(buffer, value.index);
} else if (value is KeyValueChange) {
buffer.putUint8(133);
writeValue(buffer, value.index);
} else if (value is KeyValueChangeKey) {
buffer.putUint8(134);
writeValue(buffer, value.index);
} else if (value is FriendlyObstructionPurpose) {
buffer.putUint8(135);
writeValue(buffer, value.index);
} else if (value is UIElementType) {
buffer.putUint8(136);
writeValue(buffer, value.index);
} else {
super.writeValue(buffer, value);
}
}
@override
Object? readValueOfType(int type, ReadBuffer buffer) {
switch (type) {
case 129:
final int? value = readValue(buffer) as int?;
return value == null ? null : AdErrorType.values[value];
case 130:
final int? value = readValue(buffer) as int?;
return value == null ? null : AdErrorCode.values[value];
case 131:
final int? value = readValue(buffer) as int?;
return value == null ? null : AdEventType.values[value];
case 132:
final int? value = readValue(buffer) as int?;
return value == null ? null : KeyValueObservingOptions.values[value];
case 133:
final int? value = readValue(buffer) as int?;
return value == null ? null : KeyValueChange.values[value];
case 134:
final int? value = readValue(buffer) as int?;
return value == null ? null : KeyValueChangeKey.values[value];
case 135:
final int? value = readValue(buffer) as int?;
return value == null ? null : FriendlyObstructionPurpose.values[value];
case 136:
final int? value = readValue(buffer) as int?;
return value == null ? null : UIElementType.values[value];
default:
return super.readValueOfType(type, buffer);
}
}
}
/// The `IMAAdDisplayContainer` is responsible for managing the ad container
/// view and companion ad slots used for ad playback.
///
/// See https://developers.google.com/ad-manager/dynamic-ad-insertion/sdk/ios/reference/Classes/IMAAdDisplayContainer.
class IMAAdDisplayContainer extends NSObject {
/// Initializes IMAAdDisplayContainer for rendering the ad and displaying the
/// sad UI.
IMAAdDisplayContainer({
super.pigeon_binaryMessenger,
super.pigeon_instanceManager,
required this.adContainer,
this.companionSlots,
UIViewController? adContainerViewController,
}) : super.pigeon_detached() {
final int pigeonVar_instanceIdentifier =
pigeon_instanceManager.addDartCreatedInstance(this);
final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec =
_pigeonVar_codecIMAAdDisplayContainer;
final BinaryMessenger? pigeonVar_binaryMessenger = pigeon_binaryMessenger;
() async {
const String pigeonVar_channelName =
'dev.flutter.pigeon.interactive_media_ads.IMAAdDisplayContainer.pigeon_defaultConstructor';
final BasicMessageChannel<Object?> pigeonVar_channel =
BasicMessageChannel<Object?>(
pigeonVar_channelName,
pigeonChannelCodec,
binaryMessenger: pigeonVar_binaryMessenger,
);
final List<Object?>? pigeonVar_replyList =
await pigeonVar_channel.send(<Object?>[
pigeonVar_instanceIdentifier,
adContainer,
companionSlots,
adContainerViewController
]) as List<Object?>?;
if (pigeonVar_replyList == null) {
throw _createConnectionError(pigeonVar_channelName);
} else if (pigeonVar_replyList.length > 1) {
throw PlatformException(
code: pigeonVar_replyList[0]! as String,
message: pigeonVar_replyList[1] as String?,
details: pigeonVar_replyList[2],
);
} else {
return;
}
}();
}
/// Constructs [IMAAdDisplayContainer] without creating the associated native object.
///
/// This should only be used by subclasses created by this library or to
/// create copies for an [PigeonInstanceManager].
@protected
IMAAdDisplayContainer.pigeon_detached({
super.pigeon_binaryMessenger,
super.pigeon_instanceManager,
required this.adContainer,
this.companionSlots,
}) : super.pigeon_detached();
late final _PigeonInternalProxyApiBaseCodec
_pigeonVar_codecIMAAdDisplayContainer =
_PigeonInternalProxyApiBaseCodec(pigeon_instanceManager);
/// View containing the video display and ad related UI.
///
/// This view must be present in the view hierarchy in order to make ad or
/// stream requests.
final UIView adContainer;
/// List of companion ad slots.
final List<IMACompanionAdSlot>? companionSlots;
static void pigeon_setUpMessageHandlers({
bool pigeon_clearHandlers = false,
BinaryMessenger? pigeon_binaryMessenger,
PigeonInstanceManager? pigeon_instanceManager,
IMAAdDisplayContainer Function(
UIView adContainer,
List<IMACompanionAdSlot>? companionSlots,
)? pigeon_newInstance,
}) {
final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec =
_PigeonInternalProxyApiBaseCodec(
pigeon_instanceManager ?? PigeonInstanceManager.instance);
final BinaryMessenger? binaryMessenger = pigeon_binaryMessenger;
{
final BasicMessageChannel<
Object?> pigeonVar_channel = BasicMessageChannel<
Object?>(
'dev.flutter.pigeon.interactive_media_ads.IMAAdDisplayContainer.pigeon_newInstance',
pigeonChannelCodec,
binaryMessenger: binaryMessenger);
if (pigeon_clearHandlers) {
pigeonVar_channel.setMessageHandler(null);
} else {
pigeonVar_channel.setMessageHandler((Object? message) async {
assert(message != null,
'Argument for dev.flutter.pigeon.interactive_media_ads.IMAAdDisplayContainer.pigeon_newInstance was null.');
final List<Object?> args = (message as List<Object?>?)!;
final int? arg_pigeon_instanceIdentifier = (args[0] as int?);
assert(arg_pigeon_instanceIdentifier != null,
'Argument for dev.flutter.pigeon.interactive_media_ads.IMAAdDisplayContainer.pigeon_newInstance was null, expected non-null int.');
final UIView? arg_adContainer = (args[1] as UIView?);
assert(arg_adContainer != null,
'Argument for dev.flutter.pigeon.interactive_media_ads.IMAAdDisplayContainer.pigeon_newInstance was null, expected non-null UIView.');
final List<IMACompanionAdSlot>? arg_companionSlots =
(args[2] as List<Object?>?)?.cast<IMACompanionAdSlot>();
try {
(pigeon_instanceManager ?? PigeonInstanceManager.instance)
.addHostCreatedInstance(
pigeon_newInstance?.call(arg_adContainer!, arg_companionSlots) ??
IMAAdDisplayContainer.pigeon_detached(
pigeon_binaryMessenger: pigeon_binaryMessenger,
pigeon_instanceManager: pigeon_instanceManager,
adContainer: arg_adContainer!,
companionSlots: arg_companionSlots,
),
arg_pigeon_instanceIdentifier!,
);
return wrapResponse(empty: true);
} on PlatformException catch (e) {
return wrapResponse(error: e);
} catch (e) {
return wrapResponse(
error: PlatformException(code: 'error', message: e.toString()));
}
});
}
}
}
/// View controller containing the ad container.
Future<void> setAdContainerViewController(
UIViewController? controller) async {
final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec =
_pigeonVar_codecIMAAdDisplayContainer;
final BinaryMessenger? pigeonVar_binaryMessenger = pigeon_binaryMessenger;
const String pigeonVar_channelName =
'dev.flutter.pigeon.interactive_media_ads.IMAAdDisplayContainer.setAdContainerViewController';
final BasicMessageChannel<Object?> pigeonVar_channel =
BasicMessageChannel<Object?>(
pigeonVar_channelName,
pigeonChannelCodec,
binaryMessenger: pigeonVar_binaryMessenger,
);
final List<Object?>? pigeonVar_replyList = await pigeonVar_channel
.send(<Object?>[this, controller]) as List<Object?>?;
if (pigeonVar_replyList == null) {
throw _createConnectionError(pigeonVar_channelName);
} else if (pigeonVar_replyList.length > 1) {
throw PlatformException(
code: pigeonVar_replyList[0]! as String,
message: pigeonVar_replyList[1] as String?,
details: pigeonVar_replyList[2],
);
} else {
return;
}
}
/// View controller containing the ad container.
Future<UIViewController?> getAdContainerViewController() async {
final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec =
_pigeonVar_codecIMAAdDisplayContainer;
final BinaryMessenger? pigeonVar_binaryMessenger = pigeon_binaryMessenger;
const String pigeonVar_channelName =
'dev.flutter.pigeon.interactive_media_ads.IMAAdDisplayContainer.getAdContainerViewController';
final BasicMessageChannel<Object?> pigeonVar_channel =
BasicMessageChannel<Object?>(
pigeonVar_channelName,
pigeonChannelCodec,
binaryMessenger: pigeonVar_binaryMessenger,
);
final List<Object?>? pigeonVar_replyList =
await pigeonVar_channel.send(<Object?>[this]) as List<Object?>?;
if (pigeonVar_replyList == null) {
throw _createConnectionError(pigeonVar_channelName);
} else if (pigeonVar_replyList.length > 1) {
throw PlatformException(
code: pigeonVar_replyList[0]! as String,
message: pigeonVar_replyList[1] as String?,
details: pigeonVar_replyList[2],
);
} else {
return (pigeonVar_replyList[0] as UIViewController?);
}
}
/// Registers a view that overlays or obstructs this container as “friendly”
/// for viewability measurement purposes.
Future<void> registerFriendlyObstruction(
IMAFriendlyObstruction friendlyObstruction) async {
final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec =
_pigeonVar_codecIMAAdDisplayContainer;
final BinaryMessenger? pigeonVar_binaryMessenger = pigeon_binaryMessenger;
const String pigeonVar_channelName =
'dev.flutter.pigeon.interactive_media_ads.IMAAdDisplayContainer.registerFriendlyObstruction';
final BasicMessageChannel<Object?> pigeonVar_channel =
BasicMessageChannel<Object?>(
pigeonVar_channelName,
pigeonChannelCodec,
binaryMessenger: pigeonVar_binaryMessenger,
);
final List<Object?>? pigeonVar_replyList = await pigeonVar_channel
.send(<Object?>[this, friendlyObstruction]) as List<Object?>?;
if (pigeonVar_replyList == null) {
throw _createConnectionError(pigeonVar_channelName);
} else if (pigeonVar_replyList.length > 1) {
throw PlatformException(
code: pigeonVar_replyList[0]! as String,
message: pigeonVar_replyList[1] as String?,
details: pigeonVar_replyList[2],
);
} else {
return;
}
}
/// Unregisters all previously registered friendly obstructions.
Future<void> unregisterAllFriendlyObstructions() async {
final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec =
_pigeonVar_codecIMAAdDisplayContainer;
final BinaryMessenger? pigeonVar_binaryMessenger = pigeon_binaryMessenger;
const String pigeonVar_channelName =
'dev.flutter.pigeon.interactive_media_ads.IMAAdDisplayContainer.unregisterAllFriendlyObstructions';
final BasicMessageChannel<Object?> pigeonVar_channel =
BasicMessageChannel<Object?>(
pigeonVar_channelName,
pigeonChannelCodec,
binaryMessenger: pigeonVar_binaryMessenger,
);
final List<Object?>? pigeonVar_replyList =
await pigeonVar_channel.send(<Object?>[this]) as List<Object?>?;
if (pigeonVar_replyList == null) {
throw _createConnectionError(pigeonVar_channelName);
} else if (pigeonVar_replyList.length > 1) {
throw PlatformException(
code: pigeonVar_replyList[0]! as String,
message: pigeonVar_replyList[1] as String?,
details: pigeonVar_replyList[2],
);
} else {
return;
}
}
@override
IMAAdDisplayContainer pigeon_copy() {
return IMAAdDisplayContainer.pigeon_detached(
pigeon_binaryMessenger: pigeon_binaryMessenger,
pigeon_instanceManager: pigeon_instanceManager,
adContainer: adContainer,
companionSlots: companionSlots,
);
}
}
/// An object that manages the content for a rectangular area on the screen.
///
/// See https://developer.apple.com/documentation/uikit/uiview.
class UIView extends NSObject {
/// Constructs [UIView] without creating the associated native object.
///
/// This should only be used by subclasses created by this library or to
/// create copies for an [PigeonInstanceManager].
@protected
UIView.pigeon_detached({
super.pigeon_binaryMessenger,
super.pigeon_instanceManager,
}) : super.pigeon_detached();
static void pigeon_setUpMessageHandlers({
bool pigeon_clearHandlers = false,
BinaryMessenger? pigeon_binaryMessenger,
PigeonInstanceManager? pigeon_instanceManager,
UIView Function()? pigeon_newInstance,
}) {
final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec =
_PigeonInternalProxyApiBaseCodec(
pigeon_instanceManager ?? PigeonInstanceManager.instance);
final BinaryMessenger? binaryMessenger = pigeon_binaryMessenger;
{
final BasicMessageChannel<
Object?> pigeonVar_channel = BasicMessageChannel<
Object?>(
'dev.flutter.pigeon.interactive_media_ads.UIView.pigeon_newInstance',
pigeonChannelCodec,
binaryMessenger: binaryMessenger);
if (pigeon_clearHandlers) {
pigeonVar_channel.setMessageHandler(null);
} else {
pigeonVar_channel.setMessageHandler((Object? message) async {
assert(message != null,
'Argument for dev.flutter.pigeon.interactive_media_ads.UIView.pigeon_newInstance was null.');
final List<Object?> args = (message as List<Object?>?)!;
final int? arg_pigeon_instanceIdentifier = (args[0] as int?);
assert(arg_pigeon_instanceIdentifier != null,
'Argument for dev.flutter.pigeon.interactive_media_ads.UIView.pigeon_newInstance was null, expected non-null int.');
try {
(pigeon_instanceManager ?? PigeonInstanceManager.instance)
.addHostCreatedInstance(
pigeon_newInstance?.call() ??