Skip to content

Adding showRewardVideoAd() arguments to README#643

Open
tlhunter wants to merge 1 commit intofloatinghotpot:masterfrom
tlhunter:master
Open

Adding showRewardVideoAd() arguments to README#643
tlhunter wants to merge 1 commit intofloatinghotpot:masterfrom
tlhunter:master

Conversation

@tlhunter
Copy link
Copy Markdown

Currently it's impossible to know the arguments to showRewardVideoAd without looking at the code.

Currently it's impossible to know the arguments to showRewardVideoAd without looking at the code.
@tlhunter
Copy link
Copy Markdown
Author

On second thought, these two methods are misleading. They don't actually fire based on whether a reward video is played or not. Ideally the showRewardVideoAd() API would change to accept two callbacks, one which fires when the user completes the reward operation, the other which fires if the user cancels.

There are some global events which this module will fire, but it's not easy to correlate them to a particular reward ad being played. It's also not 100% possible to correctly know if a user has earned a reward with those global events. For example, the onAdDismiss event will fire if a user dismisses a reward ad. But, it will also fire if the user successfully finishes the reward ad and then closes the video to return to the game.

I don't think this PR should be accepted, but I would like to have it trigger a discussion on updating the cordova-admob-pro API.

@erperejildo
Copy link
Copy Markdown

Is this related with the error that I'm getting now when I build my app?

BUILD FAILED in 3s
27 actionable tasks: 1 executed, 26 up-to-date
(node:29640) UnhandledPromiseRejectionWarning: Error: /Users/danielrodriguez/Desktop/repositories/party-words/platforms/android/gradlew: Command failed with exit code 1 Error output:
/Users/danielrodriguez/Desktop/repositories/party-words/platforms/android/app/src/main/java/com/rjfun/cordova/admob/AdMobPlugin.java:646: error: AdMobPlugin.RewardVideoListener is not abstract and does not override abstract method onRewardedVideoCompleted() in RewardedVideoAdListener
private class RewardVideoListener implements RewardedVideoAdListener {
^
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
1 error

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':app:compileReleaseJavaWithJavac'.

Compilation failed; see the compiler error output for details.

@floatinghotpot
Copy link
Copy Markdown
Owner

floatinghotpot commented Mar 21, 2018

Fixed in 3229136

New version of AdMob Android SDK added a virtual API, just implement:

    //@Override
    public void onRewardedVideoCompleted() {
      fireAdEvent(EVENT_AD_WILLDISMISS, ADTYPE_REWARDVIDEO);
    }

@erperejildo
Copy link
Copy Markdown

Thanks

@Ices-Eyes
Copy link
Copy Markdown

Ices-Eyes commented Mar 24, 2018

It seems that there is still some problems with this... Compiling on phonegap build returns

:app:compileReleaseJavaWithJavac/app/src/main/java/com/rjfun/cordova/admob/AdMobPlugin.java:684: error: method does not override or implement a method from a supertype

@floatinghotpot
Copy link
Copy Markdown
Owner

Please use the latest version, cordova-plugin-admobpro@2.31.3

@Ices-Eyes
Copy link
Copy Markdown

Hi. Pgb is retrieving the version from npm, and is already using that version. Looking at the error line on the code I see that on 2.31.3 you changed line 679 of AdMobPlugin.java, while now the the error is on line 684. I suppose the same problem is on another method than that you fixed.

@floatinghotpot
Copy link
Copy Markdown
Owner

@Ices-Eyes yes, you are correct. I made a stupid mistake, comment out the wrong line in a hurry. Should be line 684.

Now updated as cordova-plugin-admobpro@2.31.4.

@Ices-Eyes
Copy link
Copy Markdown

Thanks, will try it in a few moments with pgb :)

@Ices-Eyes
Copy link
Copy Markdown

It works perfectly now- Thanks! 👍

@Cycododge
Copy link
Copy Markdown

Cycododge commented Mar 25, 2018

With version 2.31.4, I am still getting the error that @erperejildo was receiving.

.../rjfun/cordova/admob/AdMobPlugin.java:646: error: AdMobPlugin.RewardVideoListener is not abstract and does not override abstract method onRewardedVideoCompleted() in RewardedVideoAdListener
private class RewardVideoListener implements RewardedVideoAdListener {

I am running cordova v8.0.0 and cordova-android v7.1.0

@floatinghotpot
Copy link
Copy Markdown
Owner

@Cycododge as the AdMob SDK API is not compatible to old version, currently you may need find the code:
https://github.com/floatinghotpot/cordova-admob-pro/blob/master/src/android/AdMobPlugin.java#L684

    //@Override
    public void onRewardedVideoCompleted() {
      fireAdEvent(EVENT_AD_WILLDISMISS, ADTYPE_REWARDVIDEO);
    }

and remove the // manually.

@Cycododge
Copy link
Copy Markdown

I'm not sure I follow. npm outdated shows that I have the latest versions.

@Cycododge
Copy link
Copy Markdown

Cycododge commented Mar 28, 2018

Removing my platforms and plugins folders, and installing clean fixed this issue.

@Terangs-K
Copy link
Copy Markdown

Terangs-K commented Apr 4, 2018

In my app when I call AdMob.prepareRewardVideoAd then always out the message 'error:3, reason: No fill, adNetwork:AdMob, adType:rewardvideo,adEvent:onAdFailLoad. Example source too. Is it OK? (My plugin version is 2.31.4) - I tested in new project but it works same...... OTL

@Slavezax
Copy link
Copy Markdown

@floatinghotpot on 2.31.4 it's with //

   //@Override
    public void onRewardedVideoCompleted() {
      fireAdEvent(EVENT_AD_WILLDISMISS, ADTYPE_REWARDVIDEO);
    }

Should we remove it manually?

@floatinghotpot
Copy link
Copy Markdown
Owner

floatinghotpot commented Apr 23, 2018

It depends.
The public void onRewardedVideoCompleted() is newly introduced in latest google play library.
If you are working with most latest google play library, @OverRide should work. You can remove the comment //.
But it will cause build error with old google play library, for example, in PhoneGap build service. So comment out @OverRide is safe to get both old and new library compatible.

@swapnilraja1212
Copy link
Copy Markdown

Fixed in 3229136

New version of AdMob Android SDK added a virtual API, just implement:

    //@Override
    public void onRewardedVideoCompleted() {
      fireAdEvent(EVENT_AD_WILLDISMISS, ADTYPE_REWARDVIDEO);
    }

How to implement ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants