kmcgill88 / admob_flutter

Admob Flutter plugin that shows banner ads using native platform views.
https://pub.dartlang.org/packages/admob_flutter
ISC License
434 stars 151 forks source link

[TargetingInfo] Added targeting info to the newest version (WeTransfer link + File in the post) #162

Open Nikolak47 opened 4 years ago

Nikolak47 commented 4 years ago

Hey! I just added targetingInfo (from the guy who failed to merge) to the newest state of the package. Too lazy to make a pull request, so I'll just upload the zip file, for someone to do it. Package (WeTransfer link): https://we.tl/t-SfTm7GqAmu

If you find any problems/bugs, message me. Will be glad if this is added to the newest version. As file: admob_flutter-withTargetingInfo.zip

yiss commented 4 years ago

I can make the pull request and implement it. Edit : also thinking maybe update the plugin to support the new plugin API used by Flutter >= 1.12

Nikolak47 commented 4 years ago

@yiss Yes, do it please :) Also, can you tell me if it shows you ads on your physical device ?

kmcgill88 commented 4 years ago

Whats up @yiss and @Nikolak47

I'm sorry I've been busy with my day job. If you have a solid solution for targeting please PR it. I'll be getting back to this project soon. I'm also going to need web support!

yiss commented 4 years ago

Hi @kmcgill88 we totally understand no worries. I'm happy to help

davidmartos96 commented 4 years ago

I would love to see this feature implemented. I'm currently using a fork which adds an optional parameter "personalizedAds" to comply with the GDPR.

yiss commented 4 years ago

@davidmartos96 can you link this fork please so that I can take a look at it ?

davidmartos96 commented 4 years ago

@yiss Sure, it's https://github.com/js2702/admob_flutter and the branch non_personalized.

yiss commented 4 years ago

Here is the pull request #164 I added the same AdRequestFactoryBuilder used by the official Flutter admob plugin the modifications work fine I tested it on my mobile device : https://drive.google.com/file/d/1eNftPAGkBXPnX8vRRs1lReMTYj83Vqt-/view

Nikolak47 commented 4 years ago

@yiss Can you tell me how to use it ? Here is my implementation, step by step:

  1. I declare MobileAdTargetingInfo kTargetingInfo = MobileAdTargetingInfo(...) *put my deviceID in 'testDevices' and 'keywords'
  2. I declare AdMobBanner and put the kTargetingInfo as parameter *tried also with Test Banner Id
  3. I launch the application to my mobile device and the ads are not showing
yiss commented 4 years ago

@Nikolak47 I use

MobileAdTargetingInfo targetingInfo = MobileAdTargetingInfo(
  keywords: <String>['flutterio', 'beautiful apps'],
  contentUrl: 'https://flutter.io',
  birthday: DateTime.now(),
  childDirected: false,
  designedForFamilies: false,
  gender:
      MobileAdGender.male, // or MobileAdGender.female, MobileAdGender.unknown
  testDevices: <String>[
    // Add the String showed in this line in the console < Use RequestConfiguration.Builder().setTestDeviceIds(Arrays.asList("AAAAAAAAAAAAAAAAAAAAAAAA") to get test ads on this device. >
    // To load ads on test devices
    //'AAAAAAAAAAAAAAAAAAAAAAAA'
  ], // Android emulators are considered test devices
);

And then I use it

interstitialAd = AdmobInterstitial(
      adUnitId: getInterstitialAdUnitId(),
      targetingInfo: targetingInfo,
      listener: (AdmobAdEvent event, Map<String, dynamic> args) {
        if (event == AdmobAdEvent.closed) interstitialAd.load();
        handleEvent(event, args, 'Interstitial');
      },
    );

    rewardAd = AdmobReward(
        adUnitId: getRewardBasedVideoAdUnitId(),
        targetingInfo: targetingInfo,
        listener: (AdmobAdEvent event, Map<String, dynamic> args) {
          if (event == AdmobAdEvent.closed) rewardAd.load();
          handleEvent(event, args, 'Reward');
        });

And for the Banner :

dmobBanner(
                      targetingInfo: targetingInfo,
                      adUnitId: getBannerAdUnitId(),
                      adSize: bannerSize,
                      listener:
                          (AdmobAdEvent event, Map<String, dynamic> args) {
                        handleEvent(event, args, 'Banner');
                      },
                    ),

I forgot to update the main.dart in example I just did :) cheers

yiss commented 4 years ago

Normally if it's working properly it should print I/Ads (30315): This request is sent from a test device. in the console

yiss commented 4 years ago

@Nikolak47 let me know if that worked for you

Nikolak47 commented 4 years ago

@yiss Thanks for the example. It works with banners, but I still can't make it work with interstitial ads...

yiss commented 4 years ago

@Nikolak47 are you using your version or mine? Because in yours you haven't implemented targetingInfo for interstitial. I did it for the interstitial and reward ad you can check it on my github : https://github.com/yiss/admob_flutter the last commit is what you need. Waiting for the PR to be merged

Nikolak47 commented 4 years ago

I'm using your version... image

yiss commented 4 years ago

@Nikolak47 weird, can you show me the console output? Does it say anything?

Nikolak47 commented 4 years ago

I think the problem with not showing interstitial Ads on the test device is 'Error: 3' (selected in red), because earlier when I was trying to load interstitial ad, it threw this error. Also, after implementing this package, I started getting the getStreamVolume isRestricted mode = 0 (selected in blue). image

yiss commented 4 years ago

@Nikolak47 Erro 3 means that the request was successful but there is no Ad to serve this can be caused by many reasons. Can you test your interstitial with the one here : https://developers.google.com/admob/android/test-ads

Nikolak47 commented 4 years ago

@yiss Thank you very much, it works! There is probably a problem with the interstitial Ad I defined in my admob account. Thanks again! :)

yiss commented 4 years ago

Alright! That's good news to hear. Glad I can help

cyberlahy commented 4 years ago

Hi, does this include the non-personalized? and which package and branch do I need or waiting the PR here? thanks

yiss commented 4 years ago

@cyberlahy yes by default it's non personalised, I made a PR waiting for it to be merged. You can check out my fork it contains the proper working version

cyberlahy commented 4 years ago

@yiss I see your code and I think it's by default "personalized" and we need to precise if it is not. Or I am wrong?

yiss commented 4 years ago

@cyberlahy by the default targetingInfo is not required, when specify targetingInfo property you're then doing a personalized ads, example : If you do targetingInfo: MobileAdTargetingInfo() without specifying any targeting info it's not personalized, if you add something like gender, date... Then it becomes personalized ads. You can check here :https://support.google.com/admob/answer/7676680?hl=en