Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flutter 颤振admob通过IAP移除ads_Flutter_In App Purchase - Fatal编程技术网

Flutter 颤振admob通过IAP移除ads

Flutter 颤振admob通过IAP移除ads,flutter,in-app-purchase,Flutter,In App Purchase,嗨,我用这种方式展示firebase admob横幅和国际广告。它展示firebase admob的广告。它的签名是firebase import 'package:firebase_admob/firebase_admob.dart'; import 'dart:io'; class AdvertService { static final AdvertService _instance = AdvertService._internal(); factory AdvertServi

嗨,我用这种方式展示firebase admob横幅和国际广告。它展示firebase admob的广告。它的签名是firebase

import 'package:firebase_admob/firebase_admob.dart';
import 'dart:io';

class AdvertService {
  static final AdvertService _instance = AdvertService._internal();
  factory AdvertService() => _instance;
  MobileAdTargetingInfo _targetingInfo;

  final String _bannerAd = Platform.isAndroid
      ? 'ca-app-pub-xxxxxxx1/5xxxxxxxx'
      : 'ca-app-pub-xxxxxxx1/2xxxxxxxx';
  final String _interAd = Platform.isAndroid
      ? 'ca-app-pub-xxxxxxx1/1xxxxxxxx'
      : 'ca-app-pub-xxxxxxx1/6xxxxxxxx';
  // FirebaseAdMob.instance.initialize(appId: appId);

  AdvertService._internal() {
    //_targetingInfo = MobileAdTargetingInfo( testDevices: <String>["54a0a4f2"]);
    _targetingInfo = MobileAdTargetingInfo();
  }
  showBanner() {
    print(_bannerAd);
    BannerAd banner = BannerAd(
        adUnitId: _bannerAd,
        size: AdSize.smartBanner,
        targetingInfo: _targetingInfo);

    banner
      ..load()
      ..show();
    banner.dispose();
  }

  showIntersitial() {
    InterstitialAd interstitialAd =
        InterstitialAd(adUnitId: _interAd, targetingInfo: _targetingInfo);

    interstitialAd
      ..load()
      ..show();

    interstitialAd.dispose();
  }
}


我想做的是制作一个IAP并删除此用户的广告。我如何做

有几种方法可以实现您的要求。
我建议您遵循本教程:

要安装此软件包,请执行以下操作:

您必须在Google Play控制台和/或AppStoreConnect上启用IAP。请记住,在应用程序中使用IAPs必须遵守谷歌和/或苹果的使用条款,因此请注意这些条款。
此外,如果你想使用“消耗品”(一种可以购买超过1次的物品),你必须在你的后端存储用户是否购买了该物品(例如在Firebase Cloud Firestore中),因为苹果和谷歌都只能存储关于用户是否购买了物品的信息,而不是他买了多少次

让我考虑一下:
管理iap可能会非常痛苦,因为这不是最简单的事情,尤其是在Flutter中,本机功能不是由开发人员直接管理的。如果你的目标只是在用户想付少量钱(比如0.99欧元或1.20美元)的情况下删除广告,我建议你创建两个版本的应用程序,一个有广告,一个没有广告,在商店出售第二个版本,当用户点击“删除广告”时,打开相应的商店,提示他下载你的应用程序的“高级版本”。你会节省很多时间和心理健康


快乐编码

非常感谢你的回答和有趣的建议。有两个不同的版本是有意义的。
final AdvertService _advertService = AdvertService();

_advertService.showBanner();

or
_advertService.showIntersitial();