I am creating an iOS8 application and started to implement iAd's Banner in code, but yesterday I discovered that I can use the canDisplayBannerAds property. I enabled it on each of the views in my application, and it is working. Previously, when I was implementing it with my own code, there was a lot of discussion about the importance of using a singleton of the ADBannerView. Does canDisplayBannerAds use a singleton, or is it violating what I had read about the importance of using a singleton? Does it really matter from a performance, advertising, and Apple Store perspective?
Thank you for your comments and feedback,
Mike
No, it uses a new one each time. I ran into that problem when first using iAd. Each vc had canDisplay... And the ads got all messed up. In fact they didn't even show up in the App Store version. Best to use either the singleton method or something similar that reuses the iAd. I myself use the app delegate. All my apps use that and I have not run into any problems at all. Good luck!
EDIT#1
Here is a link to a blog post I wrote using iAd with the app delegate. It is written in Objective-C but at least you will get the general idea. I basically create an iAd banner in the app delegate and then use that one in every vc you need.
Related
Should my app be updated to Scene Delegate from App Delegate. My app supports ios 13.0 and up
first you have to understand what is difference
You could think of them as the global and private versions. One is shared and the other is limited to the individual owner. In a way, they are exactly what you would expect by the names.
Multi-window support is happening
Next time you create a new Xcode project you’ll see your AppDelegate has split in two: AppDelegate.swift and SceneDelegate.swift. This is a result of the new multi-window support that landed with iPadOS, and effectively splits the work of the app delegate in two.
From iOS 13 onwards, your app delegate should:
Set up any data that you need for the duration of the app.
Respond to any events that focus on the app, such as a file being shared with you.
Register for external services, such as push notifications.
Configure your initial scenes.
In contrast, scene delegates are there to handle one instance of your app’s user interface. So, if the user has created two windows showing your app, you have two scenes, both backed by the same app delegate.
Keep in mind that these scenes are designed to work independently from each other. So, your application no longer moves to the background, but instead individual scenes do – the user might move one to the background while keeping another open.
at last I will say that you can go with Scene Delegate
Courtesy of https://www.hackingwithswift.com/articles/193/whats-new-in-ios-13
I want to trigger some analytics code every time a user in my iOS app moves to a new screen.
Is there a way to detect every call to viewDidAppear, or do I need to implement this in every ViewController ?
Yes, lots of the analytics suppliers frameworks offer this feature. Generally they're implemented with swizzling, so they replace the UIViewController implementation to capture the analytics and then call the stock implementation. As all your view controllers should call super then their code will be run.
It's also possible that you could create a superclass for all your view controllers but this is harder to fit into most apps.
I did something similar to one of my apps with google analytics. At that time I had to subclass my controllers from GAITrackedViewController. That pretty much did it. I added the self.screenName = #"some screen name"; on viewDidAppear method just to know where the user was on my GA Dashboard.
It was explained on the GA docs, so it won't be hard to find.
I want to implement iAds to my UITabBar application, and I discovered that if I use the canDisplayBannerAds property on each of my ViewControllers then the ads are displayed/hidden accordingly, resizing the view perfectly and it's so easy to implement (no ADBannerView added on Storyboard), but easy is almost never good.
Is there anything wrong with this? Do I need to add an ADBannerView either by code/storyboard?
There is no need to create an AdBannerView in code or the storyboard. I'm using canDisplayBannerAds in my apps and it is working fine. Apple does everything for you and you mustn't take care about memory leaks, rendering issues, error handling, ...
Is there anything wrong with this?
No, canDisplayBannerAds is easy to implement and requires no effort to manage. I usually suggest using canDisplayBannerAds when someone is placing advertisements into their application for the first time. It gets them familiar with advertisements and iAd.
Do I need to add an ADBannerView either by code/storyboard?
No, using canDisplayBannerAds does not require you to implement an ADBannerView. The moment you need an ADBannerView you'll know it. For example, you want to use another ad network for when iAd fails to receive an ad. Using canDisplayBannerAds you're not able to do this. You need the delegate methods you would inheret from using your own ADBannerView.
I am creating an iOS8+ application and am ready to add iAd to it. At this time, I've set the following in viewDidLoad() for each UIViewController in my application:
self.canDisplayBannerAds = true
Everything seems to be working properly... Ads are appearing when I switch between views. Is this the proper way to enable iAd with multiple views on iOS8 and newer releases?
I have not found any documentation that says how to use canDisplayBannerAds with multiple view controllers. I found a lot of postings for earlier releases of iOS where the developer had to implement iAd on his/her own, and only create a singleton. Anyway, I hope that someone can verify that what I have done is correct and will work properly when the app goes to the store.
Thank you for your time and help,
Mike
Boy, this is frustrating.
I sent in my app to Apple after months and months of development. It was quickly rejected due to the fact that they said it was unresponsive at the home screen. Here is the screenshot they sent me:
Now, when I build the exact archive of the app that I sent them, I have no such issues:
The buttons were created in the storyboard file and were IBOutlets, but the highscore label that you see was created programmatically. Is it possible that the storyboard file didn't upload properly? I have already messaged them in the resolution center about it and tried to submit it again to see if it would work next time, but I was wondering if anyone knew anything about this issue.
From above screenshot, I've understand something that issue related with network error. See, they were tested with flight mode. According to apple guidelines, it should be go on in home screen without much more delay. At least show an alert for this issue. Just test with this scenario, you will get this.
When they said it was unresponsive, it may be due to the fact that its stuck for certain reasons, check if you make any API call at the viewLoad method, also, if the UI may turn unresponsive incase you are performing some heavy operation on the main thread, try using a background thread of these operations
It's been an extremely long time, but I thought I'd say what was wrong in case anyone comes across this in the future. Basically, I had created the buttons in Interface Builder but was re-instantiating them in viewDidLoad of my view controller. Since IBOutlets are weak properties, they were thus being released. Why that wasn't happening when I ran it on my computer, I have no idea. Still puzzles me to this day.