flutter_google_ad_manager icon indicating copy to clipboard operation
flutter_google_ad_manager copied to clipboard

Hotfix/onRewaded does not work on iOS

Open zumikou1125 opened this issue 5 years ago • 0 comments

Overview

Fixed an error in the "onRewarded" callback function on iOS.

Modifications

  • A typo in the "type" key in the native code ( "yype" -> "type" )

    • ios > Classes > RewardedAd.swift

      func rewardBasedVideoAd(_: GADRewardBasedVideoAd,
                              didRewardUserWith reward: GADAdReward) {
          // before
          channel.invokeMethod("onRewarded", arguments: ["yype": reward.type, "amount": reward.amount])
          // after
          channel.invokeMethod("onRewarded", arguments: ["type": reward.type, "amount": reward.amount])
      }
      
  • Invalid cast error ( type 'double' is not a subtype of type 'int' in type cast )

    • lib > rewarded_ad.dart

      // before
      final void Function(String type, int amount) onRewarded;
      // after
      final void Function(String type, double amount) onRewarded;
      
          :
          :
      
      case 'onRewarded':
          var type = call.arguments['type'] as String;
          // before
          var amount = call.arguments['amount'] as int;
          // after
          var amount = call.arguments['amount'] as double;
          this.onRewarded(type, amount);
          break;
      
    • example > lib > main.dart

      // before
      onRewarded: (String type, int amount) {
      // after
      onRewarded: (String type, double amount) {
          print('rewardedAd onRewarded: type:$type amount:$amount');
      },
      

zumikou1125 avatar Oct 31 '20 15:10 zumikou1125