如何在flutter应用程序中通过应用程序内购买删除广告

时间:2020-03-09 11:58:00

标签: flutter admob in-app-purchase

我想在用户购买带有帮助应用内购买的删除广告包后禁用Admob广告。我要删除非页内广告和奖励广告,以下是非页内广告和奖励广告的代码:

  InterstitialAd myInterstitial = InterstitialAd(
    adUnitId: Platform.isIOS ? ios_ads : android_ads,
    listener: (MobileAdEvent event) {
      print("InterstitialAd event is $event");
    },
  );

  myInterstitial
    ..load()

    ..show(
      anchorType: AnchorType.bottom,
      anchorOffset: 0.0,

    );

奖励广告

 RewardedVideoAd.instance.listener =
      (RewardedVideoAdEvent event, {String rewardType, int rewardAmount}) {
    if (event == RewardedVideoAdEvent.rewarded) {

    }
  };
  RewardedVideoAd.instance.load(adUnitId: Platform.isIOS ? ios_ads : android_ads, 
  targetingInfo: targetingInfo).then((v){

    print("log "+v.toString());
    if(v){
      RewardedVideoAd.instance.show();

    }

  });

1 个答案:

答案 0 :(得分:0)

具有一个布尔值,以跟踪是否已付款以删除广告。如果此布尔值设置为true,则不要调用广告代码。

if(!isPaymentDone){
  // code to show ads
}