I have implemented google admob in my IOS app.All other adds are working e.g Banner,Native. Interstitial add is also working fine with test id during debugging mode.But when I replaced test key with actual key I got below crash on crashlytics
GADInterstitial.m line 306
__49-[GADInterstitial presentFromRootViewController:]_block_invoke
I have crosschecked keys and code from official google site.Below is the code I am using
interstitial = GADInterstitial(adUnitID: "ca-app-pub-.....") //test
interstitial.delegate = self
let request = GADRequest()
interstitial.load(request)
if interstitial.isReady {
interstitial.present(fromRootViewController: self)
} else {
print("Ad wasn't ready")
}
Is the interstitial variable a property on the class or just a local function variable? (sorry, but I do not have enough rep. to comment)
Related
I have recently upgraded to Google Mobile Ads v8. In my App, I have two Interstitial ads in the same ViewController that get displayed at unique interactions. Because of this, I need to be able to determine which Interstitial ad was dismissed in adDidDismissFullScreenContent so I can advance the UI accordingly.
Right now I am only determining if it was an Interstitial ad that was dismissed.
func adDidDismissFullScreenContent(_ ad: GADFullScreenPresentingAd) {
if type(of: ad) == GADInterstitialAd.self {
// Interstitial was dismissed
}
}
Ideally, I would like to be able to determine which ad was dismissed by adUnitID (if that is even possible).
Something like this:
func adDidDismissFullScreenContent(_ ad: GADFullScreenPresentingAd) {
if ad.adUnitID = "Ad1"{
// Do something.
} else if ad.adUnitID = "Ad2"{
// Do something else.
}
}
How can I determine which interstitial ad was dismissed using Google Mobile Ads v8?
In June, Admob adverts worked perfectly and AdMob sent a letter with a verification PIN for me to verify my identity & payment details.
Around the beginning of July, nearly all live ads stopped displaying in my app. I am still making the same number of requests, but impressions are so low I have dropped to £0.00/£0.01 a day. All test ads work correctly.
This issue began around the time I renamed my app (only on the app store display), however; all links to my app in my AdMob account are correct so the name change appears to have made no difference on their front-end UI.
When I debug my app, I get a list of warnings in the output section:
[I-ACS025031] AdMob App ID changed. Original, new: (nil), AppId
My 'GADApplicationIdentifier' value in my info.plist is the same as the 'new' app id.
[I-ACS013003] User property name must start with a letter: _ap
I am not setting any user properties, no idea what this means.
What have I tried?
Setting up new ad units.
Reverting back to an older version of the app.
Contacted AdMob 'support' via a form. They told me my ad serving is being limited. They did not say for how long and it has been around 2/3 weeks (by 'limited', I don't think they meant completely stopped).
Checked for policy violations in my account; nothing is there.
Code I use to display ads:
I have created an 'AdMobDisplayer' class that allows me to set up and display ads; this is called by each view controller. For example, my banner ads code:
View Controller:
let adMobDisplayer = AdMobDisplayer()
#IBOutlet weak var bannerView: GADBannerView!
override func viewDidLoad() {
super.viewDidLoad()
self.bannerView = self.adMobDisplayer.setupAdBannerView(self.bannerView, viewController: self, adUnitId: Constants.timerTabBannerAdId)
self.adMobDisplayer.displayBannerAd(self.bannerView)
}
AdMobDisplayer:
func setupAdBannerView(_ bannerView: GADBannerView, viewController: UIViewController, adUnitId: String, bannerViewDelgate: GADBannerViewDelegate? = nil) -> GADBannerView {
if(checkIfAdsAreDisabled()) {
return bannerView
}
/// Creates a new GADBannerView to be displayed in a view controller
bannerView.adUnitID = adUnitId
/// bannerView.adUnitID = Constants.testBannerAdId
bannerView.rootViewController = viewController
if let delegate = bannerViewDelgate {
bannerView.delegate = delegate
}
return bannerView
}
func displayBannerAd(_ bannerView: GADBannerView) {
if(checkIfAdsAreDisabled()) {
return
}
///Creates a request and loads an advert from AdMob
let request = GADRequest()
request.testDevices = [ "My Device Id" ]
bannerView.load(request)
}
This should display a banner ad in the view. It worked when I first added adverts in, it works for test adverts, but intermittently/rarely for live adverts now.
Find the full application on my GitHub: https://github.com/AlexMarchant98/KeGal-Trainer
Thanks in advance for any help!
I recently worked on GADBannerView in my last app and had almost similar issue, in your case you may need to generate Admob ad id, from their website.
So I fixed this ages ago, but, my fix was to add the required 'NSAppTransportSecurity' keys into my info.plist.
https://developers.google.com/admob/ios/app-transport-security
Is there any restriction that it is not possible to display a bannerview from Google Admob in a sharesheet? I have an app which provides additional data in the sharesheet, and I also want to display ads there. In my main app, the ads work fine - but in the sharesheet, I don't get any error message or anything when initialising the ads.
Greetings,
Jack
Update: I am using the cocoapod Firebase/Admob. This one is assigned to the main app and the sharesheet. As I have the ads on several view controlers, I created a function, which is connected via an app group to both parts. In ViewDidLoad, I initialice google admob
GADMobileAds.configure(withApplicationID: "filledwiththecorrectcode")
Then I run this function providing the view and the constrains:
func loadAdd(ViewController: GADBannerView, HightConstrain: NSLayoutConstraint, MainApp: Bool){
ViewController.adSize = kGADAdSizeSmartBannerPortrait
// TEST CODE
ViewController.adUnitID = "ca-app-pub-3940256099942544/2934735716"
ViewController.rootViewController = self
HightConstrain.constant = 50
let request: GADRequest = GADRequest()
request.testDevices = [kGADSimulatorID]
ViewController.load(request)
}
}
This works fine in the main app. In the sharesheet, I run the same function - it also walks through in the debugger, but nothing happens. Ah, the
I've implemented Firebase and originally had ad banners loading fine. But at some point along the way they have stopped showing up and i've tried everything i can think of. I have no idea what i could have changed as not much is different and certainly nothing with the Firebase or AdMob code has changed.
print("Google Mobile Ads SDK version: " + GADRequest.sdkVersion())
bannerView.adUnitID = "ca-app-pub-6956068899232786/3635179951"
bannerView.rootViewController = self
let request = GADRequest()
request.testDevices = [kGADSimulatorID]
bannerView.loadRequest(request)
I have also tried implementing the adViewDidReceiveAd() delegate function and i'm not seeing that get called either.
adViewDidReceiveAd did not call because you forget add
bannerView.delegate = self
I have the next issue with admob. I created app for iOS 8 in swift using the latest admob sdk and I when I debug this app on the simulator I see test ads, when I debug on the real device I see the real ads. But when I published the app to the app store I see test ads.
I have not set up any test ads on the device or in the account adb it must show ads in simulator only, but I see test ads in release build on the AppStore.
Maybe I doing something wrong? I have not requested testing on any device so it must show me real ads on any real device but it does not.
My code
override func viewDidLoad() {
super.viewDidLoad()
self.bannerView.adUnitID = "my id"
self.bannerView.rootViewController = self
var request:GADRequest = GADRequest()
self.bannerView.loadRequest(request)
//other setup code which is not related to ads
let tracker = GAI.sharedInstance().defaultTracker
let build = GAIDictionaryBuilder.createAppView().set("Custom event", forKey: kGAIScreenName).build() as NSDictionary
tracker.send(build as [NSObject : AnyObject])
}
Other controller
override func viewDidLoad() {
super.viewDidLoad()
var interstitial : GADInterstitial = GADInterstitial()
interstitial.adUnitID = "interstitial ad id"
var request: GADRequest = GADRequest()
interstitial.loadRequest(request)
//other setup code not related to ads
}
I was provided by wrong advertiser id. So fix is obvious - just recheck your ad unit id before release.