Interstitial Ads For Iphone Preload - swift

I am trying to implement an interstitial ad for iPhone. My code currently works, but the ads are slow to appear (I know that I need to check if an ad is available). Is there a way to initiate iAd at start up, maybe in the appDelegate so that when my view appears the ad is ready?
Here is how my views are laid out.
Gameplay_View -> Score -> Ad -> Gameplay_View
Since I'm using three separate UIViews I'm not sure how to implement the Ad and have it load in a timely manner.
Thanks in advance!

I know there is a line of code available for ads to be preloaded, i haven't managed to try it out yet but if your curious here it is.
This is how i declared my Interstitial Ad (Just as a reference since the line of code uses the name).
var interstitialAd:ADInterstitialAd!
When the game has ended have this line of code and it is 'meant' to preload the interstitial ads for the current view controller (I say again i have not tested this to see if it works, this is just if your curious).
UIViewController.prepareInterstitialAds()

Related

Show Interstitial more than once Admob at Ionic

I have developed cross platform application using Ionic 1 framework,
for the admob I have used cordova-admob-pro plugin.
https://github.com/floatinghotpot/cordova-admob-pro
For the Interstitial showing, used following code portion. When I open up a page, an Interstitial is displayed for a while.
Upto now Every thing is fine.
The problem is when I have attempted second and more times ,Interstitial is not displayed any more until I have killed an application then open it again.
Same problem is seen at both platform Android and IOS.
What should I do?
I have any problem with another banner at the top of the screen, it keeps displayed during application life cycle.
// preppare and load ad resource in background, e.g. at begining of game level
if(AdMob) AdMob.prepareInterstitial( {adId:admobid.interstitial, autoShow:false} );
// show the interstitial later, e.g. at end of game level
if(AdMob) AdMob.showInterstitial();
Each time before you call showInterstitial(), you must call prepareInterstitial() to load ad resource from server, and expect a onAdLoaded event.
In your code, you call showInterstitial() only once when init, which is not enough.
https://github.com/floatinghotpot/cordova-admob-pro/issues/568

Implement a single iAd banner across entire multi page app using Swift

Does anyone know how to implement a single iAd banner that sits at the top level of your app so that every view controller that is displayed contains the same instance of the single iAd banner?
I had an implementation a few years ago in Obj-C but cannot find an equivalent in Swift.
As the user above me said what you are looking for is a shared banner ad. You don't need to move the delegates to app delegate.swift, you just need to add the properties there.
https://developer.apple.com/library/ios/technotes/tn2286/_index.html
I made an ad helper for swift, why don't you check it out.
https://github.com/crashoverride777/Swift-iAds-and-AdMob-Helper

Interstitial ads using iAds on iPhone

It seems there are 2 options for displaying interstitial ads using iAds on iPhone. The documentation on interstitials is out of date, but according to the iAds Additions Reference all one needs to do to set up is:
[UIViewController prepareInterstitialAds];
[self setInterstitialPresentationPolicy:ADInterstitialPresentationPolicyManual];
followed by:
[self requestInterstitialAdPresentation]
(which returns a bool if successful) whenever you'd like to display an ad.
The other options is to manually create an interstitial ad object:
ADInterstitialAd *interstitial;
Then:
interstitial = [[ADInterstitialAd alloc] init];
interstitial.delegate = self;
And when you want to show an ad:
if (interstitial.isLoaded) {
[interstitial presentFromViewController:self];
}
However PresentViewController: is deprecated, and using presentInView:self.view means the ad doesn't have a close button. The compiler also suggests requestInterstitalAdPresentation.
So one would assume option 1 is the preferred approach. I'm a little confused by the answer to this question as it uses a combination of the 2, but it seems requestInterstitalAdPresentation doesn't trigger the delegate methods of the ADInterstitialAd instance and using both is pointless.
So my question is - is the first approach really sufficient? I've found it only displays one ad, and then fails to display any more. I read in another question that the ADInterstitialAd instance needs to be assigned to nil in order to request a new ad, but then requestInterstitialAdPresentation ignores this instance anyway. Is requestInterstitialAdPresentation just simulating low fill rates? Or am I missing a step?
It's only showing 1 ad because there is a delay implemented by apple. You must wait 2 or 3 minutes before they will supply you with your next ad.
As for implementation, the new method calls viewDidAppear in your view controller when the user returns from the ad.
You can see my implementation here...
https://stackoverflow.com/a/27536872/3489816
So to answer your question - Yes, the first approach is sufficient. It will display more ads but you must wait for a bit. You shouldn't use AdInterstitialAd anymore so don't worry about setting it to nil. It's not simulating low fill rates. I don't think you're missing anything... we were just never told we had to wait :)
Side note... I believe setting the interstitialPresentationPolicy also requests your first ad for you (as prepareInterstitialAds does).
The first method you describe is exactly what I've just got working, and it does generate new advertisements, not just one. You have to call
[self requestInterstitialAdPresentation]
every time you want to show an advert. The advert isn't always shown, and your iPhone developer settings can make this worse.
I've got some code that does this and waits for completion here.

How to place an ad popup like scene in andengine

I want to start placing ads in my andengine game and an ad to appear just before my result display screen (for example fruit ninja). Since My result screen is a scene and not an activity, I want an ad to popup after my game play and just before results and on button click the ad disappears. I think there is a class called popupscene, but i am not sure if that is to be used. Can someone help?
I made an example using the GLES1 version of the engine:
https://github.com/zfoley/AndengineAdmobLayoutExample
The main thing is to use a LayoutGameActivity instead of a BaseGameActivity.
LayoutGame activity supports having additional views in addition to the GLSurfaceView.
Once you have that going, its pretty simple to implement the admob API or whatever ad service you are using. In my example I use admob.

Taking an iAd across multiple screens

I'm sure there's a simple answer to this but it's beginning to annoy me now!
I have an iAd integrated into my app which appears and works on the screen I've implemented it in. The app uses a NavigationController to move between multiple screens, but the iAd is only on one of them. After moving from start to finish through my app several times I get a message appear in GDB saying:
Too many active banners (11). Creation of new banners will be throttled.
The app then crashes.
I have tried looking through the Apple documentation and searched on Google and can't see a solution to the problem.
If anyone has any idea how I can resolve the issue it would definitely stop me from going mad! Thanks.
It sounds like you're not removing your iAds when views hide. I suggest doing the creation in viewWillAppeaer and removing ads in the viewDidDisappear method. Like this, you'l only end up with as many banners as you create in the visible view. It sounds like you're using the viewdidLoad/viewWillUnload pair instead.
Another alternative is to create the ADBannerView in a fixed location across all screens. It's a little bit harder than the above method, but it looks nice. For example, if you have a tab bar controller application, you can do the following in your app delegate:
[self.myTabBarController.view addSubview:self.myAdView];
It can get a little bit tricky to place other views underneath the ad.