-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[interactive_media_ads] Adds initial iOS implementation #7063
base: main
Are you sure you want to change the base?
Conversation
@stuartmorgan @jmagman I'm getting an error when importing the IMA SDK on iOS. How should I handle importing the SDK so the that it works with apps using and not using Swift Package Manager. I currently have it included in the Also here are the iOS docs for importing the IMA SDK for reference: https://developers.google.com/interactive-media-ads/docs/sdks/ios/client-side The error:
|
packages/interactive_media_ads/ios/interactive_media_ads/Package.swift
Outdated
Show resolved
Hide resolved
dependencies: [ | ||
.package( | ||
url: "https://github.com/googleads/swift-package-manager-google-interactive-media-ads-ios", | ||
from: "3.23.0") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want upToNextMajor
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the iOS team already have policy on this? On Android, I think we only use pinned versions because gradle lacked the equivalent of a Podfile.lock
or pubspec.lock
. Should we be consistent with Android or should iOS implementations generally use upToNextMajor
if possible?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pinning is sort of a myth on Android because of optimistic upgrades. For CocoaPods we've generally allowed major version ranges for dependencies with an authoritative/trusted source (e.g., the vendor of the thing the plugin is wrapping).
I added a comment to Package.swift, does that fix it? cc @loic-sharma |
...ios/interactive_media_ads/Sources/interactive_media_ads/ViewControllerProxyAPIDelegate.swift
Show resolved
Hide resolved
@@ -37,6 37,7 @@ class AdDisplayContainer extends StatelessWidget { | |||
AdDisplayContainer({ | |||
Key? key, | |||
required void Function(AdDisplayContainer container) onContainerAdded, | |||
TextDirection layoutDirection = TextDirection.ltr, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This value is required for UIKitView
, so I added to the interface.
class TestBinaryMessenger<T>: NSObject, FlutterBinaryMessenger { | ||
let codec: FlutterMessageCodec | ||
var result: T? | ||
private(set) var handlers: [String: FlutterBinaryMessageHandler] = [:] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we ever actually need the functionality provided by all these ivars? I would expect that any real test would use a fake Pigeon API instance, not a fake messenger, since tests shouldn't be relying on Pigeon internals, so this functionality seems like a potential footgun.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. I think I originally was planning on using the handles, but ending up not. I removed all this code.
packages/interactive_media_ads/ios/interactive_media_ads.podspec
Outdated
Show resolved
Hide resolved
contentPlayhead: IMAContentPlayhead? | ||
) throws -> IMAAdsRequest { | ||
let adTagWithRequestAgent = | ||
"\(adTagUrl)&request_agent=Flutter-IMA-\(AdsRequestProxyAPIDelegate.pluginVersion)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What guarantees that this concatenation is valid? E.g., if adTagUrl
doesn't have a ?
, or has a #
, this wouldn't work.
...e_media_ads/ios/interactive_media_ads/Sources/interactive_media_ads/FlutterViewFactory.swift
Outdated
Show resolved
Hide resolved
..._ads/ios/interactive_media_ads/Sources/interactive_media_ads/InteractiveMediaAdsPlugin.swift
Outdated
Show resolved
Hide resolved
packages/interactive_media_ads/lib/src/android/android_view_widget.dart
Outdated
Show resolved
Hide resolved
|
||
/// Adds a method to convert native AdErrorType to platform interface | ||
/// AdErrorType. | ||
extension NativeAdErrorTypeConverter on ima.AdErrorType { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These should be stand-alone utility functions, per https://github.com/flutter/flutter/blob/master/docs/contributing/Style-guide-for-Flutter-repo.md#avoid-using-extension
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did this for Android as well. I'll update that as well
// A delay is added since this callback only indicates when the View is | ||
// created, but not when it has been added to the native View hierarchy. | ||
// See https://github.com/flutter/flutter/issues/150802 | ||
await Future<void>.delayed(const Duration(seconds: 1)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we think this is going to always be enough time?
final IOSAdsManagerDelegate adsManagerDelegate = IOSAdsManagerDelegate( | ||
IOSAdsManagerDelegateCreationParams( | ||
onAdEvent: expectAsync1((AdEvent event) { | ||
expect(event.type, AdEventType.allAdsCompleted); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like these tests only expect within the callback, in which case failing to call the callback wouldn't fail the test. If that's the case, these should all have a completer declared up front, and completed with the expectation, so the end of the test can also assert that the completer completes (and thus the test did call the callback).
iOS implementation for flutter/flutter#134228
Pre-launch Checklist
dart format
.)[shared_preferences]
pubspec.yaml
with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.CHANGELOG.md
to add a description of the change, following repository CHANGELOG style, or this PR is exempt from CHANGELOG changes.///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.