BUG 1.0.0-beta5 - Rewarded ads, "amount" parameter datatype (int on Android, double on iOS)
Using prerelease 1.0.0-beta5 with rewarded ads I'm having issues processing reward config in the listener code. The "args" map that contains the reward info (filled in AdMob) is not processed in the same way on Android and iOS. More exactly, the "amount" parameter, which natively is an integer, is solved on Android as an int (correct) but as double on iOS (incorrect).
In my listener code I had this:
...
if (event == AdmobAdEvent.rewarded) {
var amount = var amount = args['amount'];
print('Reward amount: $amount - type: ${amount?.runtimeType}'); // int on Android - double on iOS
...
The workarround for now is quite simple:
...
if (event == AdmobAdEvent.rewarded) {
var amount = var amount = args['amount'];
// BUGFIX amount parameter
if (amount is double) {
amount = (amount as double).truncate();
}
print('Reward amount: $amount - type: ${amount?.runtimeType}'); // now it's int on both Android and iOS
...
@henry2man thanks for reporting this. Do you have bandwidth to PR a fix for this to make things consistent?
Honestly I don't have much experience with native iOS development (I suspect this needs some Swift/Objective C tweaking).
I will try to fix it but I cannot promise anything 😅
Hey @henry2man, I can help you on this one if you want :wink:
I did a fast bird's-eye view of this issue.
In this case the swift code is very straightforward... the code is calling Google Ads iOS SDK directly.
AFAIK the "amount" parameter should be an integer so it's likely a mistake in the Google SDK.
@kmcgill88 What do you think? Should we apply a quick-n-dirty patch until Google SDK is fixed?