xamarin / GoogleApisForiOSComponents

MIT License
225 stars 162 forks source link

How do I set fullScreenContentDelegate for AppOpenAd? #595

Open datvm opened 1 year ago

datvm commented 1 year ago

I need to know when a user dismisses the open ad. The official documentation has this:

@interface AppDelegate
    : UIResponder <UIApplicationDelegate, GADFullScreenContentDelegate>

// ...

self.appOpenAd.fullScreenContentDelegate = self;

I can't see the equivalent in AppOpenAd class. Did I miss something? How do I handle these events? My current code looks like this (error handlings etc are removed for brevity):

this.ad = await AppOpenAd.LoadAsync(
    o.IosUnitId,
    null,
    o.Orientation switch
    {
        AppOpenAdOrientation.Landscape => UIInterfaceOrientation.LandscapeLeft,
        _ => UIInterfaceOrientation.Portrait,
    }
);

var oldHandler = ad.PaidEventHandler;
var openTcs = new TaskCompletionSource();

// The handler below is actually called when the ad show up
ad.PaidEventHandler = v =>
{
    oldHandler?.Invoke(v);
    openTcs.TrySetResult();
};

var root = Platform.GetCurrentUIViewController();
this.ad.PresentFromRootViewController(root);
MarvinFrankenfeld commented 1 year ago

We have the same problem, anybody got any solution?

datvm commented 1 year ago

@MarvinFrankenfeld Can you check this comment on StackOverflow? I am not sure what he was trying to say but if you understand what he means and if it's successful, could you tell me? Thanks.

P.s.: so far our app get approved with open-ad with the above (my) code, I add a 1000ms delay before closing the loading screen just to be sure. That's our current workaround.