larpon / QtFirebase

An effort to bring Google's Firebase C++ API to Qt + QML
MIT License
284 stars 83 forks source link

Resize ad banner on screen orientation change #55

Open demiantres opened 6 years ago

demiantres commented 6 years ago

On iOS (probably also Android) the ad banner does not adapt to a change in the view's width or height properties. The ad banner view should issue a new ad request in case the width or height changes. As an alternative (or better addition) it would be useful to manually tell the ad banner view to send a new ad request.

larpon commented 6 years ago

Have you tried setting a new width/height/AdRequest and then reloading the banner? (you can force reload the banner by calling load()) - I've thought about having a wrap around load() called reload() for clearity

demiantres commented 6 years ago

I have played around with this but without success because the ad size is set once in the "init()" (respectively "initInternal()" (patch) method.

demiantres commented 6 years ago

Do you want to to take a look on this, or shall I provide a patch?

larpon commented 6 years ago

Ah I see - you're absolutely right.

I think the problem, then, is that it requires a full banner initialization - which earlier (back when I first wrote the code) would crash.

I can see that we call Destroy safely now - but I'm not sure it can be re-initialized a second time. It might be a left over from trying to keep it stable. But it may also have something to do with AdMob not allowing this on same AdUnitId?

You are welcome to provide a patch - watch out for issue #11 Also watch out for inconsistency between the use of the Position enum and x/y - x and y values aren't updated if you use the Position enums - I never got it to work (but haven't looked at it since v2.1.0 or so)