Saturday, June 26, 2021

Facebook Ad Debuggings

After doing the below, app was not showing test ads and neither the real ads. 

var bannerAdView: FBAdView!

 func loadBannerAd() {

        NSLog("loadBannerAd ENTRY")

        bannerAdView = FBAdView(placementID: "516263056231409_519678395889875", adSize: kFBAdSizeHeight50Banner, rootViewController: self)

        bannerAdView.backgroundColor = UIColor.red

        bannerAdView.frame = CGRect(x: 0.0, y: 20.0, width: self.view.bounds.size.width, height: 50.0)

        let testmode = FBAdSettings.isTestMode()

        print("testmode ",testmode)

        bannerAdView.delegate = self

        self.view.addSubview(bannerAdView)

        bannerAdView.loadAd()

    }

    func adView(adView: FBAdView, didFailWithError error: NSError) {

        NSLog("adview didFailWithError ")

    }

     

    func adViewDidClick(adView: FBAdView) {

        print("adViewDidClick tap on ad view")

        NSLog("adViewDidClick ")

    }

    

    func adViewDidLoad(adview:FBAdView){

        NSLog("adViewDidLoad ENTRY")

        NSLog("adViewDidLoad ")

    }

    

    func adView(didFailWithError error: NSError) {

        NSLog("Error loading ads ", error)

        print(error)

    }


running on the simulator, the testmode was giving  false. However, from the FBAdSettings simulator supposed to 


the main methods used for debugging were 

  let testDeviceHash = FBAdSettings.testDeviceHash()

  print("testDeviceHash HAsh is ",testDeviceHash)

  FBAdSettings.addTestDevice(testDeviceHash)



FBAdSettings.setLogLevel(FBAdLogLevel.debug)


This actually gives the error like below 


2021-06-27 10:55:33.061994+0530 TestDev[77253:1940584] [FBAudienceNetworkLog/FBAdProvider:164 thread:1 <error>] Ad request error: Error Domain=com.facebook.ads.sdk Code=1001 "No fill" UserInfo={NSLocalizedDescription=No fill, FBAdErrorDetailKey={

    msg = "No fill";

}}


And looking at the error code descriptions from the link in references, 


When testing your ad placements, Facebook will intentionally send a no-fill for about 20% of requests to allow you to test how your app handles the no-fill case.


And this below was an important point 


Test Mobile Apps

Once you have added a test user and added their test device, distribute your app to your test user's devices using your preferred distribution method.

Your test user must have the Facebook app installed on their device and login with the account you added as a test user. This is required to allow Facebook to serve your test user your ads.

Your test user can now trigger a test to see a production ad. See step 5 and 6 of the Add a Test Device section.

And below were the no fill reasons

  • Error 1001 - No Fill. May be due to a number of reasons including:
  • User not logged into Native Facebook App on Mobile Device
  • You have informed Facebook through the setAdvertiserTrackingEnabled flag to not deliver personalized ads via Audience Network.
  • The person did not give permission for Facebook to use their activity, that other apps and websites send to Facebook, to personalize the ads Facebook delivers to that person.
  • No Ad Inventory for current user
  • Your testing device must have the native Facebook application installed.
  • Your application should attempt to make another request after 30 seconds.

references:

https://developers.facebook.com/docs/reference/ios/current/class/FBAdSettings/

https://developers.facebook.com/docs/audience-network/setting-up/testing/platform#errors

https://developers.facebook.com/docs/audience-network/setting-up/test/checklist-errors/


No comments:

Post a Comment