vegidio / flutter-appodeal

A Flutter plugin to display ads from Appodeal; it supports consent dialog to track users.
https://pub.dev/packages/appodeal_flutter
MIT License
31 stars 19 forks source link

[BUG] Callback of one function is fired for another #12

Closed alectogeek closed 3 years ago

alectogeek commented 3 years ago

I call Appodeal.show(AdType.NON_SKIPPABLE), but provided to Appodeal.setNonSkippableCallback function is never triggered. Function provided to Appodeal.setRewardCallback is triggered instead.

Platform: Android Appodeal package version: 0.3.2

nixxxon commented 3 years ago

Hi @alectogeek !

It looks from the code that the function passed to Appodeal.setNonSkippableCallback would never trigger, will look into this.

I can also confirm that the function passed to Appodeal.setRewardCallback is also called for non skippable (and vice versa).

vegidio commented 3 years ago

@alectogeek Thanks for reporting this bug.

@nixxxon Thank you too for your willingness to look into this issue. Actually I was already looking at this problem some time ago and I also found the problem in the line below: https://github.com/vegidio-flutter/appodeal/blob/be9e15bd0b33f499be9685ff2e2e519b1683f356/lib/src/appodeal.dart#L105

It was previously calling onRewarded instead of onNonSkippable 🤦‍♂️

I fixed this now and I also did some small code refactoring (I separated the callbacks in different files on Android), but for some reason the the Reward ads are still triggering the Non-Skippable callbacks, and vice-versa.

Unfortunately I don't have much time now to continue the investigation because my primary job is taking a lot of my time, but I decided to push the changes that I did so far to master. In case you, or anybody else, is interested to continue the investigation of this issue then you are welcome to do so and open a PR 🙂

Thanks for contributing to this project!

nixxxon commented 3 years ago

@vegidio No problem, it's only fair since we are quite dependent on your plugin - thank you for creating it :clap:

I couldn't find anything else that seemed wrong with the callback code (other than the fix you mentioned). I've asked Appodeal if its a known bug within the SDK.

Will continue with the investigation and keep you posted here.

nixxxon commented 3 years ago

I just got a reply from Appodeal, turns out that this is an expected behavior since non-skippable video inherits methods and properties from rewarded videos.

It actually looks like the reversed from this image (reward inherits from non-skippable?):

reward-non-skippable

Seems a bit weird but I guess it's not coming from the plugin then. Need to understand the plugin more to say if there is something to do about it.

vegidio commented 3 years ago

Hi @nixxxon, thank you very much for following up with Appoeal support team about this issue. It was actually driving me crazy because I had no idea why it was still failing even though the bug was fixed 😅

In any case, in my opinion it's a little weird how even though the Non-Skippable ads inherit from Reward (or vice-versa), when we present one of them it triggers the callback of both types of ads 🤷‍♂️ - They say that this behavior is expected, but it doesn't look very practical for us, developers.

Oh well, it seems that we can't do much to fix this problem them. What do you think?

nixxxon commented 3 years ago

@vegidio I totally agree. Will dig through the code some more, but I'm afraid it's not much that we can do about it.. :disappointed:

vegidio commented 3 years ago

Yeah, unfortunately it seems there's not much we can do for now since this behavior is coming from the Appodeal lib. We can come back to this issue again in the future if the Appodeal guys ever decide to do something about it. But thanks again @nixxxon for helping with this :)

@alectogeek Sorry we couldn't find a solution for your problem. There was indeed a bug in the plugin's code, but I could never imagine there was also a problem in the way Appodeal lib for Android and iOS was designed.