Skip to content

Feature/admob 2021 adview, fullscreen listeners #713

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

Merged
merged 64 commits into from
Nov 8, 2021

Conversation

DellaBitta
Copy link
Contributor

@DellaBitta DellaBitta commented Oct 29, 2021

Description

 - iOS & Android dependencies increased to latest AdMob version to support AdClicked events.
 - Implemented AdListener, FullScreenContent, and PaidEvent listeners. These listener signatures track closely with the iOS and Android counterparts so that they may easily be expanded and supported.
 - Removed PresentationStateListeners. Similar functionality is now facilaited by AdListeners and FullScreenContentListeners.
 - Methods for ad placement renamed from MoveTo to SetPosition to align with AdMob's iOS and Android SDKs.
 - Invoking methods on BannerView and InterstitialAds now properly fail on "uninitialized" objects. Previously empty / invalid futures were returned from most methods.
 - Fixed an hang on loadAd calls for uninitialized BannerViews and InterstialAds.
 - More thorough shut down / destruction of ad objects ensure consistency and reduce potential flake.
 - Integration test updates:
   - New manual tests track Bounding Box, AdView, FullScreenPresentation and Paid events when clicking through ads.
   - Added higher-fidelity checks of bounding box state. Bounding box change behaviors across Android and iOS are now consistent.
   - Added a "stress" test of loading and releasing 10 BannerView ads and 10 Interstitial Ads in tight succession.
   - Destroy() is now called to properly clean up BannerViews.
   - Expanded coverage of error scenarios: uninitialized ads, duplicate load requests, etc.


Testing

Updated iTest sources.
Manually tested on iOS and Android.
iTest CI Run


Type of Change

Place an x the applicable box:

  • Bug fix. Add the issue # below if applicable.
  • New feature. A non-breaking change which adds functionality.
  • Other, such as a build process or documentation change.

CompleteFuture(kAdMobErrorAlreadyInitialized,
kAdAlreadyInitializedErrorMessage, future_handle,
&future_data_);
} else {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove the else clause so this looks like a major deletion. It's not, it appears again below.

Future<LoadAdResult> BannerView::LoadAd(const AdRequest& request) {
if (!CheckIsInitialized(internal_)) return Future<LoadAdResult>();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of these methods were returning futures that hadn't been completed..!

@@ -143,42 +139,39 @@ public void initialize(Activity activity) {
public void destroy(final long callbackDataPtr) {
// If the Activity isn't initialized, there is nothing to destroy.
if (mActivity == null) {
completeBannerViewFutureCallback(callbackDataPtr,
ConstantsHelper.CALLBACK_ERROR_NONE,
ConstantsHelper.CALLBACK_ERROR_MESSAGE_NONE);
return;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixes a bug when calling destroy on an uninitialized BannerView. Previously it would hang as the future was never completed.

Base automatically changed from feature/admob_2021_adresult to feature/admob_2021 November 1, 2021 17:56
Copy link
Contributor

@jonsimantov jonsimantov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved with a few notes.

// LINT.ThenChange(//depot_firebase_cpp/admob/client/cpp/src/include/firebase/admob/banner_view.h,
// //depot_firebase_cpp/admob/client/cpp/src/include/firebase/admob/native_express_ad_view.h)

// LINT.ThenChange(//depot_firebase_cpp/admob/client/cpp/src/include/firebase/admob/banner_view.h)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we still have IfThisThenThat, so it might be cleaner to get rid of these. Unless there is a GitHub check equivalent - that would be awesome.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. Yeah, I'm actually removing some of the stuff in here in the next PR, so I'll remove those, too. I didn't know this was related to IFTTT!


extern "C" JNIEXPORT void JNICALL
Java_com_google_firebase_admob_internal_cpp_BannerViewHelper_notifyAdClosed(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as my comment on a previous PR, consider shortening these names since they are passed into RegisterNatives anyway. (And you can put them in an anonymous namespace as well.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, it'll be part of the RewardedAd PR for Android.

@@ -53,11 +53,62 @@ METHOD_LOOKUP_DEFINITION(ad_view, "com/google/android/gms/ads/AdView",

namespace internal {

// Contains data to invoke Initailize from the main thread.
struct InitializeOnMainThreadData {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 keep Java helper code as small as possible

// Default no-op implementation for each listener method so that applications
// need only implement the methods they're interested in.
AdListener::~AdListener() {}
void AdListener::OnAdClicked() {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aside from the destructor (which needs to be here), WDYT about inlining the other implementations so it's clear to developers writing subclasses that they don't need to call the base class methods?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure! I'll put this in the next change as well, to reduce merge conflicts.

@DellaBitta DellaBitta merged commit bd8110e into feature/admob_2021 Nov 8, 2021
@DellaBitta DellaBitta deleted the feature/admob_2021_adview_listeners branch November 8, 2021 20:58
@github-actions github-actions bot added the tests: in-progress This PR's integration tests are in progress. label Nov 8, 2021
@github-actions
Copy link

github-actions bot commented Nov 8, 2021

❌  Integration test FAILED

Requested by @DellaBitta on commit bd8110e
Last updated: Mon Nov 8 14:58 PST 2021
View integration test log & download artifacts

Failures Configs
messaging [TEST] [ERROR] [Android] [All os] [android_target]
storage [TEST] [ERROR] [iOS] [macos] [ios_target]

Add flaky tests to go/fpl-cpp-flake-tracker

@github-actions github-actions bot added the tests: failed This PR's integration tests failed. label Nov 8, 2021
@firebase-workflow-trigger firebase-workflow-trigger bot removed the tests: in-progress This PR's integration tests are in progress. label Nov 8, 2021
@firebase firebase locked and limited conversation to collaborators Dec 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla: yes tests: failed This PR's integration tests failed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants