Nathan de Vries: Good afternoon everyone.
My name's Nathan de Vries [phonetic] and today I'm going to be talking to you about iAd Integration into your Apps.
Now there are two major opportunities the iAd presents to developers.
The first is promoting your applications with the new iAd Workbench feature that was announced this week.
And the second thing is a revenue opportunity for your applications.
So using application to generate revenue through advertising, and that's what we're going to be talking about today.
How to integrate iAds into your applications to generate revenue.
Now we're going to be doing that by going through this flow.
We're going to start by talking about the developer benefits of iAd specifically.
Why it might be a good choice for you to generate revenue in your applications.
Then we're going to look at some core concepts that are critical in understanding why your application is generating revenue in the way it is, how you can improve on that revenue by making adjustments to your application, and we're also going to go into a little bit more detail beyond those core concepts and talk about specific things that you can do to optimize ad performance in your applications.
Next we're going to briefly look at how to join the iAd network.
It's very easy.
And lastly, which is the major chunk of the presentation which you're all here for, is to look at some of the developer API's for integrating iAds into your application.
So let's start with the developer benefits.
First and foremost, ignoring ads all together, you put huge amount of effort into your applications, which they mix with applications that have won the design awards, blood, sweat and tears get poured into your applications.
So you really want experiences within your application that match the amount of effort that you put in.
So first and foremost, we really want to delight your customers.
So that's why the advertisements with iAd have very high production values.
We put a lot of attention to detail into the ads so that your users get the same beautiful enriched experiences that they expect from your app.
As part of this rich experience, iAd support media, playback, and game-type experiences, really adding to the features of your application.
Like your application that has access to amazing API's on the platform like Gyroscope and Cameran and so on, ads also have access to these API's.
The ads are seamlessly integrated with iOS' software and as hardware, so there's not this sandboxed limited experience inside an ad.
It's just an app.
And this creates this kind of immersive experience for the user.
If they choose to engage with an ad, it feels like this amazing experience for them.
And that's what we're really trying to achieve.
And you can see here the types of examples of ads where you can really shake the app and it interacts with the ad, or you can play music or a game, watch move trailers.
These are all the kinds of things that advertisers are providing in their ads.
And lastly, even though when the user engages in an ad and their in this [inaudible] experience, their still in your app.
So as soon as I dismiss the ad, they're right back in your app where they left off.
Just seamlessly in and straight out again.
So because the ad is inside your app, we value the privacy of the users of your application.
This is why we request permission before asking for contact access in your application, or photo access, because we really value the privacy of the users of your application.
Likewise, with advertising, we also have that same approach to privacy.
So we handle the privacy, so you don't need to worry about it.
Users start using ads within your application have the same privacy thought about that we do for your app.
The world's best brands are using iAd.
So all around the world we have agencies working with brands, winning design awards for advertising, using the iAd platform.
So all creating is, these brands are very familiar to your users, so their much more likely to engage in the advertising, and that really drives the immersive experience for the users.
Every year we're expanding so far.
We started in the U.S. We've recently rolled out into Mexico.
There's 11 countries now that we support.
So there's a great opportunity, not just to advertise locally, but also broadly, and we'll speak about that a little bit later.
It's also a menu here to work out how to monetize your application.
It's a great path to revenue.
When your application displays an advertisement, the advertising revenue that's generated from the display, and the interaction with those ads, 70% of that revenue goes to you as a developer.
So we think that's a really great way for you to make money with your applications.
And lastly, as developers, it's incredibly easy to implement.
You'll be able to jump to that later on when we go into the developer details, but we really feel like we've made it as easy as possible for you to integrate ads into your application.
There's no need to link against additional SDK's, so no need to maintain and download other SDK's.
You can be up and running in really small amount of code.
We also have some great sample code which you'll notice on the email@example.com website, which I'll link to a little bit later.
This provides the iAd Suite sample code, as well as developer documentation.
If you were to really dive in and see examples of how to integrate ads into your application.
And lastly, we think that's always been pretty easy to integrate ads, but we've made it even easier this year with iOS 7.
So we're looking forward to your feedback on some of the new stuff.
Next let's have a look at some core concepts.
Integrating iAds into your application from a developer point of view is incredibly easy.
You'll get up and running very quickly.
But there are some core concepts related to advertising and iAds specifically that are useful to have in the back of your mind when you're integrating the ads because once you've shipped your application, it's in the app store, and customers are using your app, you're going to need to track the progress of revenue generated by your app.
So some of these core concepts are going to keep coming up in your sales reports and changes that you need to make to your application to improve some of the ad performance, so we'll start there.
First of all, what is the iAd App Network?
Well we mentioned briefly that there's the two things that that the iAd network really provides to developers; the path to revenue, which we're talking about today, and also the promotional aspect promoting your app.
So the iAd App Network is the Apple business team working with advertisers to produce inventory and delivering them to you, the developer that's integrating iAds.
So what does this look like?
You've linked your application against the iAd framework.
What this means is that the iAd framework is going to send requests to the iAd App Network on your behalf asking ads.
So we send ad requests to the App Network, which replies, as you'd expect, with ads.
So this combination of two things: The requests being sent to the network and the ads being sent back form this concept called the Fill Rate.
Those of you that are familiar with advertising probably have heard of this before, but this is the measure of performance of requests sent by all of your applications, versus the ads that are delivered by the network.
And we'll come back to that when we're talking about improving app performance.
Once you've been delivered an ad, you still have to display it on the screen, so just getting an ad isn't enough, you have to show it to the user.
That's the point of this.
So that's called an impression.
As soon as you display an ad to a user, it's called an impression, and a certain percentage of those impressions will hopefully turn into Tap Throughs when the user engages with the ad.
And these two concepts combined are called the Tap Through rate.
So the number of Tap Throughs, versus the number of impressions that you're shown in your app.
And you'll see these as well in your reports when you're measuring the performance of your app.
So that's a few of the core concepts.
We'll refer back to them later on in the presentation.
Next let's look at some tangible things that you can do to improve the ad performance of your application before you even get started with the code.
So first and foremost, it all starts with a great app.
You need to focus on the customer.
Your app needs to have utility and be useful, so ignoring the advertising side of things, your app just has to be something that you want lots of people to use.
They find it really useful.
They come back to it.
There's loyalty associated with your app.
People just really have to want to use our app.
I'm recommending going to some of the sessions on design during the conference, or watching them on the videos, because honing is part of your app.
It is going to be a key to the success of advertising in your app.
Having a great app, or something that's worth talking about will generate network effects.
So you'll start getting reviews on the app store, people will talk about your app, and all of these things result in more ad requests.
So as a side effect of focusing on the customer and your app, you're immediately going to get more ad requests, more ads served, which is better for your app.
The next thing that you can do is to place ads smartly.
Key here is not place ads everywhere.
You have to really consider user context, as well as recognizing high use areas in your application, so when you're looking at a holistic view of your application, really consider is this view appropriate to advertising how many users are entering into this part of my app.
You want to avoid accidental taps.
So placing ads in spots where users might accidently tap the ad isn't a good thing because it might be an impression, but if people are tapping on the ad and immediately dismissing it because it was a mistake?
That's not going to be very good for your ad performance.
And really keep in the back of your mind when you're designing your apps and integration of ads into your apps, that user context is incredibly important.
So you really need to weigh up the benefit of an impression versus what the user was trying to do when you were showing that ad.
So things like showing advertisements during registration.
Maybe you want to show advertisements after registration because the success of your app is predicated on someone signing up, enjoying the app, and coming back to the app, which will produce more advertising revenue for you.
You should also consider customer location.
I mentioned that we support 11 different countries at the moment.
So you should take this into account when you're planning your marketing strategy.
If you're only serving your app to, say, the states, then maybe you should consider serving to other regions because these regions will also be sending ad requests, but not getting anything back.
Or they might not even have the app available in the store.
So really consider where you're submitting your app, to which stores, and take into account these iAd App Network countries.
One thing that you can do with this is target your marketing to those countries.
So if you've never thought about advertising specifically to a particular country, maybe you should try doing that?
That will increase the number of customers in that country, and really drive up those ad requests, and assist with optimizing the ad performance of your application.
You could even consider going a step further and localizing your applications.
The last country that we rolled out the iAd App Network to was Mexico.
It's right next door and you could localize our app in Spanish, and immediately get access to a whole bunch of customers that you would never have had access to before.
Driving up ad requests, impressions, Tap Throughs, and improving your app performance.
Another thing that you need to consider is the seasonality of advertising.
Consumer spending throughout the year fluctuates, so as does advertising spending.
Advertising spending kind of tracks consumer spending, right?
So you should also market accordingly.
If you know that there's going to be a holiday period coming up where spending is going to be increased, maybe you should focus your marketing attention to that time of the year.
Increase a little bit of your marketing budget, get some more customers into your apps at that point in time, and then you'll get more requests at that time.
And, I guess the one thing to take away from this is it's a very, it's a feedback loop.
As you drive more customers to your app, you're going to get more ad requests, which are going to result in more ads, which in turn turns into impressions, and Tap Throughs, and the iAd App Network will use all of these things to decide should I send more ads to this app?
How many ads should I send to this app?
So a really healthy app is one that works with this feedback loop that really drives as many customers as possible, creates loyalty, and gets more ads.
So that's a little bit about optimizing ad performance.
You might be wondering, well how do I join the iAd App Network?
It's pretty easy.
If you've submitted an app before, you would have gone to the iTunes Connect website, so the iAd preferences configured in the same place.
All you need to do is complete the iAd contract once.
And then on a per app basis, you need to enable iAd specifically for that app.
One thing to bear in mind is that you need to do this before you submit your app.
So before you've finished developing your app and maybe you want to create the descriptions and the screenshots, and so on, the App Store details for your app, make sure you enable iAd before you submit the binary for our application.
So that's a little bit about joining the iAd App Network.
Let's dig in to some of the developer details about integrating apps into your application.
And to start with, what we're going to do is talk about banners.
The banner ad is a slim device with view.
Sits at the bottom of your content view.
And you can see one here.
It's typically a place at the bottom of your content, but remember back to the smart placement bit of the talk where you can adjust this depending on music context to avoid accidental taps, but our guidance is that it generally goes to the bottom of the content.
As new ads become available, the banner continuously loads, so if your user passes out of network access and comes back into network access, these banners will automatically bring in new ads, and roll on and off the screen automatically.
When you tap one of these banners, you get a full screen immersive ad experience.
And lastly these banner ads are supported on both iPhone and iPad.
So you can use them in both contexts.
To integrate these banners, there's three easy steps.
First you need to link the iAd framework, which is pretty easy.
We're going to get a demonstration of that soon.
You need to import the iAd header from the framework.
And lastly, you need to choose the view controllers in your application that are appropriate for advertising.
So what I mentioned before, that you had an app with the banner view across the bottom, you should consider each screen of your application as being appropriate or inappropriate to the banner ads.
And we've got this new API and iOS 7 that allows you to set a flag on any of your View Controllers to say, I would like banner ads to be displayed in this View Controller.
So we set the canDislayBannerAds property to yes.
And what this does is it takes the root view, or the top level view of your View Controller, and it becomes the originalContentView.
It becomes a mute property.
This allows us to wrap your View Controller's view in a Framework View which allows us to animate the banner on and off the screen.
So when you sent the canDisplayBannerAds property to yes, we wrap your view in another view.
We start sending ad requests to the network saying we would like banner ads for this particular device.
When the banner loads, so we get an ad back from the network, the banner moves on screen, adjusting the size of your original content view.
So the one thing you need to keep in mind is if you're referring to that original view, you now need to change all of your calls to view on your View Controller to originalContentView.
And you also need to make sure that your originalContentView respects Relay Out, accommodating a new banner ad.
Once the banner is on the screen, the user has an opportunity to tap on it.
So we get that full screen ad experience on tap.
When the ad appears on the screen, you get the usual appearance and disappearance callbacks on your View Controller.
So what you should do in the viewWillDisappear callback is poise and intensive media activities, sounds, and so on, that would interrupt with the ad experience.
Because your goal is to have the user enjoy the ad experience, and not feel like the app is using up CPU, slowing things down, because that disrupts the ad experience.
When the full screen advertisement is dismissed, then this is a good time to resume any immediate activity that you had running in your app.
So now we've got an ad on screen.
The user passes out of network connectivity, or there's no longer ad Inventory available to your app, the ad unloads.
So when the ad unloads, the banner is moved off-screen automatically by the framework, and your original content view is resized much in the same way as it was resized when it was bought on the screen.
So you've got these View Controllers and they're all configured, or some of them are configured with canDislayBannerAds.
There are certain circumstances where you want a temporarily disable banner ads on a particular View Controller.
So we support that as well.
You simply need to set the property back to No.
And when you're finished with the app context, where it's inappropriate for a banner ad to be displayed, or not ideal for a banner ad to be displayed, then you can set that property back to Yes.
Don't forget to re-enable.
Yes. We provide some great tools for testing during development.
In the Developer Settings pane on the device, we have these two great facilities for adjusting the Fill Rate, which we mentioned in the core concepts.
This allows you to configure your application so that it never gets ads.
It always gets ads or some variation in between.
This is as this was with testing of your app.
You can also adjust the Refresh Rate.
So this is how quickly ads cycle in and out of your application.
One thing to bear in mind is that this only affects your apps.
So if you're carrying a development device and you total these Fill Rate and Refresh Rate settings, and then you run another person's app from the store that has iAds, it's not going to affect the Fill Rate and Refresh Rate of that app.
It's only apps that are installed by you as a developer.
I'd like to bring up David Wilson to give us a demonstration of how to integrate banner ads into our application.
David Wilson: So now that we've talked about banner ads, we're going to take a quick look at a demo, just how easy it is to take an existing application and add this functionality to it.
To do that, we're going to start off with a simple application.
It's just two View Controllers.
It's a master detail.
The first one's going to show a list of article headlines, and when you tap on one of those article headlines, you're going to go into New View Controller that shows that article in a web view.
What we want to do in the first part of this demo is to add a banner view to the bottom of the list of articles.
So I'm going to go ahead and pop open the iOS Simulator here, and this is the application before we started doing anything to it.
We've got top news here, a list of quick articles.
We can click on one of these and we've got ourselves an article.
So let's see what we need to do to add iAd Support to this application.
We're going to hide this, go back, to Xcode to bring up our project.
And the first thing that we need to do is link against the iAd framework.
So we're going to make sure we've got our project selected.
Select the appropriate target here.
And go over the Build Phases Tab.
Click the Plus Button.
We can find the iAd Framework.
And go ahead and add that to our project.
The next thing that we need to do is go into our Master View Controller here and Import the iAd Header.
That gives us access to the API, specifically the CanDislayBannerAds Property on View Controller.
Once we've done that, all we need to do is set that property on the View Controller when it wakes up.
We can go ahead and save.
We can re-run our demo here.
Now you'll see that automatically.
An ad pops in from the bottom as soon as the ad request is made, and a new ad has loaded into your application.
If we were to lose network connectivity and this were to cycle back out, you'd see it just animate out smoothly just as well as it animated in.
And with that, I'll bring Nathan back up to continue the slides.
Nathan de Vries: Thanks, David.
As you can see, it's pretty easy to enable banner ads.
Just a simple property.
Very easy to do.
This is new in iOS 7.
So next we're going to talk about a different type of ad.
We've seen a banner ad which when tapped, presents a full screen advertisement.
The Interstitial is a little bit different, in that it doesn't have that intermediary view that you tap on.
It immediately launches into a full-screen advertisement.
So what usually happens is, as you're transitioning from one part of your application into another part, you get this full-screen advertisement up here.
So this is pretty cool.
This has been available since iOS 4.3 on iPad, as of iOS 7, this is all also available on the iPhone, so you can start using this today on iPhone too.
Now when I talk about automatic presentation of a full-screen view, when does that happen?
As of iOS 7, we now have this new property on View Controller similar to the property on the banner ads called the Interstitial Presentation Policy.
And what the iAd framework is now able to do for you is watch for View Controllers to become visible, and then present an interstitial ad automatically when that view becomes visible.
So if you've got a view controller, we can say there's two View Controllers here; one is off-screen, the current View Controller on-screen, and the next View Controller off-screen.
We want to configure the Interstitial Presentation Policy of the next View Controller to be automatic.
We want the iAd framework to automatically manage presentation of an interstitial when it's appropriate based on inventory and minimum time between interstitial presentations.
Now when we call pushViewController to present that View Controller, an interstitial is automatically presented on top.
When the user dismisses the full-screen interstitial, they're back to that next View Controller.
They're back into the app.
There's also another option for applications that are doing, maybe single View Controller style, have the single View Controller architecture.
Things like games, where you need to have control over the presentation of the interstitial because there's no View Controller transitions.
So what you need to do there is instead of setting an automatic Interstitial Presentation Policy, you set a Manual Presentation Policy.
And what this does, is it still enables interstitials to present automatically and seamlessly, but you need to request the presentation.
So if you're building a game style application, when you transition from, say, the game back into the menu would be one example.
You can call Request Interstitial Presentation, and if an ad is available, it will present.
One thing to bear in mind with interstitial ads is that when you're setting this property on View Controllers that might happen quite a while after the user has launched the application.
Setting the property on a View Controller is really the only way for the iAd framework to know that ad requests should stop being sent to the iAd App Network.
So what you can do to improve on this is to call Prepare Interstitial Ads early on in your application's lifecycle so that you don't miss those early impressions.
And with that, I'm going to bring David back up to do a demo.
David Wilson: Okay.
So we're going to go back to the application we just took a look at, and we added a banner view to the bottom of the list of articles, and now we want to add interstitial presentation when the user taps on one of those articles to go into the actual article view.
We can go back, remember, and this is what our app looked like when we last left it.
We've got ads at the bottom, and you can see that they're cycling there.
We can go back to Xcode.
Now as Nathan mentioned, it's important to tell iAd that you're going to want to present interstitial as early as possible in the app's lifecycle.
That allows iAd to go ahead and make ad requests on your behalf so that an interstitial is ready when the user takes the action that would present it.
So the first thing we're going to do is we're going to go over to our app delegate.
We're going to import the iAd Header here, and then inside our app delegates did finish launching with Options Call.
We want to go ahead and call UIViewController, Prepare Interstitial Ads.
This allows iAd to begin making those ad requests at the beginning of your application.
That means the moment the user takes action, we're going to have ads available for you.
Once we've done that, we can go back to our Master View Controller here, and we've already imported the iAd Header, which was the important bit.
And we go down to the bottom of this to prepare for segue.
Here we've set up our Detail View Controller.
We've set the Article URL on it.
And once we've done that, we just also need to set one more property, which is the Interstitial Presentation Policy.
And once we've done that, we can save again.
We can go ahead and Run.
Okay. So we've got our application back up.
Give it a second and the banner should kick in here.
And then behind the scenes, we're also making interstitial requests which we'll be loading an ad for us.
Note that the default fill rate for development of the application is 80%.
You will want to change that again as Nathan pointed out if you want to test things work all the time, versus never, go ahead and click on one of the articles here, and not get an ad.
We got one down there.
There we go.
So the user's tapped on the article headline.
They've gone in the article view, and the full-screen ad has presented over the article view.
Once the user has finished engaging with this ad, they can go ahead and close that ad, and they're back immediately into your View Controller.
And with that, I'll bring Nathan back up to continue the slides.
Nathan de Vries: So simply, setting the Interstitial Presentation Policy on your View Controllers, and you get this automatic view controller interstitial presentation.
It's pretty easy.
Pretty easy to get started.
So next we're going to look at this ad type called the IAB Medium Rectangle Advertisement.
So what is this?
It's a view that's very similar to a banner view, except instead of being positioned at the bottom of your content, it's positioned in-line with your content.
The size of this view is prescribed by the Interactive Advertising Viewer, which is why it's called the Medium Rectangle Advertisement.
You might have seen this on websites.
It's 250 points by 300 points.
It also has a similar cycling behavior as the banner view, so as new ads become available, the ad cycle in the view.
And, again, like the banner content, you also get full screen ads on tap.
This was introduced in iOS 6 [inaudible], and it's available only on iPad.
So how do we create one of these things?
As you noticed, it was positioned in-line in the content, so you have this greater flexibility and positioning of the view within your content.
So to do that, we need to create this banner view of type medium rectangle.
So here you can see after we've imported the headers like we did for the banner view, we created this new banner view of type medium rectangle.
And this is going to create nearly unloaded medium rectangle view.
So we also need to configure ourselves as the delegate of this view because as ads become available and unavailable inside this banner view, we need to be told so we know when to present the view onscreen and take it off screen.
So we set ourselves as the delegate, and the protocol that's used to talk to that delegate is the 80 Banner View Delegate protocol.
So whichever object you've assigned as the delegate needs to conform to the 80 Banner View Delegate protocol.
So we do that as well.
When the banner is ready to load, so we get this Delegate Callback.
That callback is called the Banner View Did Load Callback.
Called on the delegate.
And when this happens, that's an opportunity for you to present the ad on screen.
We now have an ad fulfilled by an ad request.
We now need to turn that into an impression.
So to do that, you can do your custom layout however you would like to present that view.
You could cross-fade it in, readjust your other views, and present that medium rectangle ad in-line with your content.
Similarly to banner ads, when the medium rectangle is tapped, you get the full-screen ad.
You also need to use the view will disappear and view will appear callbacks to pause any activity and sounds in your application to prevent them clashing with any sounds and media that are being played in the ad.
When it comes time to unload that medium rectangle, the next callback you'll receive on our Delegate is called the bannerviewdidFailToReceiveAd with Error Callback.
And this is an opportunity for you to remove due to the reverse of adding the view to the view hierarchy, and you want to move it off screen.
It's important to keep in mind here that you shouldn't just throw away the medium rects ad view because you can just keep it around.
It'll continue to cycle with new ads.
So as those new ads become available, you can simply add the same medium rectangle ad view back to your views hierarchy.
So much like banner ads, we have some tools for testing medium rectangles.
We still have the adjustments to fill rate.
They also work with these medium recs.
We have adjustments to refresh rate.
Same as we discussed before.
But there's another additional toggle that you can flip used for medium rectangles because you're positioning them often in very specific ways in line with content, and what that switch does is it helps you avoid any clipping of that ad view.
So we really want to avoid clipping the ad view because that can prevent the user from being able to see it or the user being able to tap it, so by flipping the highlight clipped banners, you get these overlaid red or green views on top of your medium rects to show whether it's being clipped or not.
So make sure that you run your application with this flag enabled in Settings to make sure your medium rects aren't being clipped.
So let's get a demo of that.
David Wilson: Okay.
So to enter it medium rectangles into an application is a little more complicated, as Nathan mentioned.
So to do that, we're going to start with a new application, and this is sort of a bit of a game simulation.
Most of the screen is going to be taken up by the simulation.
There's some text at the bottom that has some wasted white space, and we're going to try to take advantage of some of that white space, to include a medium rect in the bottom left corner of our screen.
Okay. So, anyway, you just have to trust me that we have as a simulation at the top, and we have some text at the bottom, and we've got a medium rectangle that we're going to want to put on the bottom left corner of the screen.
So to do that, as we did in our previous project, the first thing we're going to need to do is link against the iAd framework.
So click on our project here, go over to Build Phases for the appropriate target.
Link binary with Libraries.
And we're going to link in the iAd framework.
Remember this is an iPad only feature, so we can't actually demo it with the iOS 7 STK today.
But you can build applications to run against iOS 6.1, and they will work with the next seed for iOS 7.
Once we've linked against the iAd framework, the next thing we need to do is go to our View Controller.
We're going to go ahead and Import the iAd framework here to give us access to these API's.
And because we need to have a delegate for the medium rect banner view, we're going to make our View Controller that 80 Banner View Delegate, and then we're going to set up a couple properties to hold the new 80 Banner View Medium Rect that we're going to create, and to keep track of whether or not the ad is currently visible on screen.
We're going to need this so that we can do the appropriate layout as the banner view loads and unloads.
So once we have those properties inside Load View, we can go ahead and instantiate that.
Note that all we have to do is alloc initWithAd: ADAdTypeMediumRectangle, and then remember to set the delegate to the View Controller.
Once we've done that, we need to update our viewDidLayoutSubviews method so that we can include the medium rect inside our layout.
So all we need to do here is do some frame calculations for the medium rect, which puts it, with the calculations here we're doing is layout out the medium rect in the bottom left of the screen if it's loaded, and just off-screen in the bottom left, if it's not loaded.
That allows us to do smooth animated transitions on and off screen, as the loaded property of this banner view changes.
To do that, we're also going to need to adjust the origin of the frame that's next to it.
Once we've done that, then we need to actually start implementing the delegate method callbacks that will tell us when things happen with this banner view.
So the first thing we're going to do is go down to the bottom and hide the rest of this.
Then we go to first start out by implementing bannerViewDidLoadAd.
This is our cue to move the banner onscreen if it's not already there.
This is iAd telling us that there's a new ad that's in place in the view and we should display it to the user.
If it's already visible, that's fine.
We don't need to take any action.
If it's not, we're going to set our property here and then we're just going to do a quick animation to move this thing onscreen by just calling setNeedsLayout, layoutIfNeeded, and letting the layout code that we did up above handle this for us.
Now once the banner's been onscreen for a little while, we're going to have to move it back off screen if it unloads, say the user moves out of network connectivity, or we just run out of inventory.
So we're going to implement in this case the bannerViewDidFailToLoadAd with error method.
This is almost identical to moving it onscreen, except we're going to change our property to No, and then we're going to again do an animation based on setNeedsLayout, layoutIfNeeded.
So that'll move the thing on and off screen, but there's one more thing we need to take care of, and that's pausing our game when the user actually interacts with this ad.
We've got a simulation running.
It's taking up CPU.
Maybe the user is actually interested in watching that simulation, and we don't want to let it just go on behind the scenes while the user's interacting with the ad.
So to do that, we're going to go ahead and implement view did appear, view did disappear on our view controller, and all we need to do here is start and stop timers that are running our simulation.
If you had media, this would also be your cure to pause and then resume the media.
Once we've done that, if our demo machine were working we could run it again, but that's pretty much all you need to do to get medium rects integrated into your app.
And with that I'll bring Nathan back out.
Nathan de Vries: So the next ad type which we're excited to talk about today, is the pre-roll video ad.
We've had a lot of requests for this, and it's new to iOS 7, and what this lets you do is integrate seamlessly with the media player API's to request playback all the video before your video content.
So as I said, it's brand new in iOS 7.
It's integrated with the media player API's.
So the way you would normally play back media with the MP movie player controller API, you can now just use a different API to play a pre-roll ad before that media.
When the pre-roll starts playing, this happens before the media content starts playing, your primary media content starts playing, and when the advertisement finishes, you get this seamless transition to the main content video.
If the user engages with the video while it's displayed with this pre-roll video, they get that standard full-screen immersive ad experience as well.
Just like all of the other advertisements we support.
We also support Inline playback.
So if you've got an application that doesn't assume full-screen media playback, then you can also use pre-roll video in that scenario by using the embedded style for MP movie player controller, and this is supported on both iPhone and iPad.
So let's take a look at how to create one of these MP movie player controllers.
In addition to the usual iAd framework import that you need to do for the other ad types, the MP movie player controller functionality is in the media player framework.
So you'll need to link media player and also import the media player headers.
We then need to create a new MP movie player controller, or an MP movie player view controller, depending on your application, and set the content URL of that movie player controller.
This is the usual video content that you would have been playing before you started integrating iAd.
After we've done that, instead of calling the play method on the movie player controller, iAd has this new category method called playPrerollAdWith CompletionHandler, which allows you to provide a completion block that gets called after the ad finishes, or if there was no other ad available at the time of requesting a pre-roll ad.
Once you've called this API, you can immediately add, so inside that handler, once the playback has finished, or if there wasn't a pre-roll available, that's your opportunity to call the play API and play your original video content.
Once you've called this Play Pre-Roll Ad with Completion Handler API, you can then add the movie player controllers view to your view hierarchy, or you can present the movie player view controller in your application.
If you've got an app that has a scenario where you would like to conditionally play pre-roll for some users and not others, or maybe you've got some time based logic as to when you want to show pre-roll ads, you can do that too.
All you need to do is call the play API instead of calling the Play Pre-Roll Ad with Completion Handler API.
And you can come up with your own logic for when you do and you don't, display pre-roll ads, and which situations are optimal for your app.
Much like interstitial ads, you also need to prepare early.
You need to tell the ad framework that it should start sending requests as soon as the application launches, so that the first time that a user taps on a video, a pre-roll ad is more likely to be available.
It's all about not missing those early impressions.
So similarly to the UIViewController, preparing [inaudible] ads called, we now swap that with an MP movie player controller prepare pre-roll ads [inaudible].
And this will do the same effective thing.
It's sending off ad requests as soon as your application becomes available.
So there are a couple of gotchas with the movie player controller API.
Those of you that are already using MP movie player controller will need to keep in mind that you may need to adjust your application to accommodate pre-roll ads.
The first thing that you need to make sure of is that if you're ever explicitly playing your MP movie player controller, you need to make sure that that doesn't happen until the completion handler is pulled.
This is because it's the main content starts playing while the pre-roll is playing, we'll immediately skip to the main content.
So bear that in mind.
There's two slightly indirect times that this can happen.
Many people will observe these two notifications on MP movie player controller, when the video becomes available for playback, and also when the first frame of the video is available for display.
A lot of developers use these and rightly so, for playing back the media content, but you need to be aware that if you call play in response to these notifications, you may skip the pre-roll adds, so make sure that you don't handle these notifications until after the callback handler is called, and likewise if your customizing the UI of the MP movie player controller, which is supported.
You also need to hold off on inserting any custom views into the view controller's view until after that completion handler is called because you don't want your views colliding with any of the pre-roll content.
And let's bring David up for a demo of that.
David: To start off with to demonstrate pre-roll adds, we're going to start with this very simple collection view application on the phone.
Just has one view controller that's a collection of views, and hold a set of thumbnails for videos, and the user can tap one of those thumbnails to go into the video.
We can go ahead and see what that looks like.
We have a few short videos here.
We can tap one of them, and the video plays.
What we want to do is instead of just having the video play immediately, we want to put a pre-roll in front of that video so we can monetize our application.
So let's take a look at what that takes.
So we're going to pull up Xcode again.
The first thing we need to do, as we did in the previous two demos, is to go ahead and make sure we link against the iAd framework.
We'll go ahead and click on our project, make sure the right target is selected, build phases, and link against the iAd framework.
Once we've done that, just as with the interstitials, it's important to tell iAd early in the application's lifecycle that you want pre-roll ads.
This allows it to go ahead and make requests early, so that a pre-roll is available when the user takes an action that should show one.
So to do that, we're going to again go to our app delegate application didFinishLaunchingWithOptions.
We're going to go ahead and import the iAd header and the media player header.
This gives us access to both the MP movie player controller class and the prepared pre-roll ads category that iAd adds to that.
So inside didFinishLaunchingWithOptions, we're just going to call MP movie player controller prepare pre-roll adds, and that kicks off the ad requests so that we can have a pre-roll ready when the user taps on one of our thumbnails.
Speaking of that, we next need to take care of actually doing that when the user taps on one of the thumbnails.
So to do that, we're going to go to our view controller.
We're going to go back up to the top first, and we're going to import the iAd header here as well.
We've already imported the media player framework since we're playing the videos.
And then we're going to go down to the bottom and we're going to go to our collectionViewdidSelect ItemAtIndexPath.
This is where we handled that tap and begin playing the movie.
All we're doing at the moment is instantiating an MP movie player view controller and setting the content URL, and then presenting it.
The only change we need to make here is to insert a call to play pre-roll ad with completion handler.
A note that we're calling MPV controller movie player play inside the completion handler.
So once the pre-roll has finished or has failed to play, we'll go ahead and play our content.
Once we've done that, we can go ahead and run this again.
We've launched application.
You see we've changed almost nothing here.
We still got our collection of videos.
And this time when the user taps on one of these videos, if an ad is available, a pre-roll should play before it.
And here we go.
We've got these are tapped, we've got the ad coming up, the ad is playing, a few seconds later, the user will be able to either watch this ad to completion or skip through.
And when that finishes, the video immediately begins playing.
And that's all it takes to integrate pre-rolls into your application.
With that, I'll bring Nathan back up.
Nathan de Vries: So as you can see, if you've already got a movie player application, it's very easy to port it across the playing pre-roll ads.
If you don't, then it's very easy to add these experiences to your app.
So wrapping up a little bit, we have these brand new pre-roll ads available in iOS 7.
Some great new opportunities for video apps to produce more revenue from their application with pre-roll ads.
We have those medium rectangle ads that are supported on the iPad that can be positioned in-line with your content for a more integrated experience.
We have new interstitial support for iPhone, which is new in iOS 7.
They're also supported on iPad.
And lastly we have these new banner controller API's similar to the interstitial API's that allow you to simply toggle a switch on your view controllers to opt in to advertising for those content views.
And lastly, we spoke a little bit about optimizing your ad performance, so when you go away and you're thinking about integrating these advertisements into your application, think back to these tips for optimizing ad performance, placing ads smartly, looking at specific regions and locales for the way you might want to optimize your marketing, and lastly, make sure that it all starts with the app.
Really focus on pleasing your customers and you'll generate far more revenue from your applications.
For more information about these slides and iAd-related questions, you should speak to our director of technology evangelism, John, or you should jump onto the forums and ask questions there.
We have a whole bunch of us that answer questions.
To develop documentation as I mentioned is part of the developed benefits.
Is incredibly thorough.
So there's the iAd Sample Suite that you want to check out, and also the new develop a documentation for these new API's that we're launching this release.
There's some related sessions if you're interested in promotion of your application, as well as making revenue from your application.
You should check out the videos of the iAd workbench session.
And if you're interested in content creation for advertising, then there's also two sessions related to producing the ads themselves.
Thank you very much.
[ Applause ]