admob_flutter icon indicating copy to clipboard operation
admob_flutter copied to clipboard

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

Open Nikolak47 opened this issue 5 years ago • 24 comments

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

Nikolak47 avatar May 12 '20 22:05 Nikolak47

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

yiss avatar May 14 '20 23:05 yiss

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

Nikolak47 avatar May 14 '20 23:05 Nikolak47

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!

kmcgill88 avatar May 15 '20 00:05 kmcgill88

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

yiss avatar May 15 '20 09:05 yiss

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.

davidmartos96 avatar May 15 '20 10:05 davidmartos96

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

yiss avatar May 15 '20 10:05 yiss

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

davidmartos96 avatar May 15 '20 10:05 davidmartos96

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

yiss avatar May 15 '20 14:05 yiss

@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

Nikolak47 avatar May 15 '20 15:05 Nikolak47

@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 avatar May 15 '20 15:05 yiss

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

yiss avatar May 15 '20 15:05 yiss

@Nikolak47 let me know if that worked for you

yiss avatar May 15 '20 18:05 yiss

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

Nikolak47 avatar May 15 '20 19:05 Nikolak47

@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

yiss avatar May 15 '20 19:05 yiss

I'm using your version... image

Nikolak47 avatar May 15 '20 19:05 Nikolak47

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

yiss avatar May 15 '20 19:05 yiss

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

Nikolak47 avatar May 15 '20 20:05 Nikolak47

@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

yiss avatar May 15 '20 20:05 yiss

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

Nikolak47 avatar May 15 '20 20:05 Nikolak47

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

yiss avatar May 15 '20 20:05 yiss

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

cyberlahy avatar May 18 '20 17:05 cyberlahy

@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

yiss avatar May 19 '20 23:05 yiss

@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?

cyberlahy avatar May 20 '20 05:05 cyberlahy

@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

yiss avatar May 20 '20 08:05 yiss