I am trying to integrate Audience Network to my app. Ads work correctly on simulator and device when I deploy over XCode.
I want to distribute the build over TestFlight
If you have your ads in many places you can put this code in the AppDelegate
Swift 3
import FBAudienceNetwork
private func facebookAdsControl() {
#if RELEASE
self.clearTestDevicesForFacebookAds()
#else
self.addTestDevicesForFacebookAds()
#endif
}
///remove for live mode
private func addTestDevicesForFacebookAds(){
let key = FBAdSettings.testDeviceHash()
FBAdSettings.setLogLevel(FBAdLogLevel.Log)
FBAdSettings.addTestDevice(key)
}
///add for live mode
private func clearTestDevicesForFacebookAds() {
FBAdSettings.clearTestDevices()
}
This code will make sure that your test ads show on testflight or the simulator/device and also will make sure when you release to the app store that your ads will be shown as LIVE ads and the test devices will be cleared.
call the: facebookAdsControl()
in the didFinishLaunchingWithOptions
You can also call this code in the code where you have the ads but make sure you call it before adView.load()
In order to use the macro you have to add the flags to your Swift Flags in the Build Settings
I hope this helps someone as the Facebook Docs are not very clear as I have found out.