IOS Development AD access IAD framework _inmobi framework __ios

Source: Internet
Author: User
Tags set background uikit
iOS development of embedded advertising, commonly used advertising framework to achieve, commonly used by Apple's official: iad and the three-party image: InMobi, etc. The following are described separately:

iad framework

IOS 4.0 introduced the IAD Framework (iad.framework) support program to display banner ads. Ads are made up of standard view, you can insert them into your user interface and display them when appropriate. View itself communicates with Apple's advertising service, dealing with everything from loading and displaying advertising content to responding to clicks.

For more information on using IAD in your programs, see the IAD Programming Guide and the IAD framework reference manual.

I. IAD framework Brief Introduction

IAD is an advertising platform launched by Apple to help developers get revenue from apps. instance Steps

1. Create a simple view based application

2. Select the project file, then select the target, then select the frame and add iad.framework.

3. Update ViewController.h as shown below

#import <UIKit/UIKit.h>
#import <iAd/iAd.h>
@interface viewcontroller:uiviewcontroller< Adbannerviewdelegate>
{
    adbannerview *bannerview;
}
@end

4. Update VIEWCONTROLLER.M, as shown below

#import "ViewController.h"

@interface viewcontroller ()

@end

@implementation viewcontroller

-(void ) viewdidload
{
    [super viewdidload];
    Bannerview = [[Adbannerview alloc]initwithframe:
    cgrectmake (0, 0,)];
    Optional to set background color to clear color
    [Bannerview setbackgroundcolor:[uicolor Clearcolor]];
    [Self.view Addsubview:bannerview];
}

-(void) didreceivememorywarning
{
    [super didreceivememorywarning];
    Dispose of any of the can is recreated.
}

#pragma mark-adviewdelegates

-(void) Bannerview: (Adbannerview *) banner 
 Didfailtoreceiveadwitherror: ( Nserror *) error{
    NSLog (@ "error loading");
}

-(void) Bannerviewdidloadad: (Adbannerview *) banner{
    NSLog (@ "Ad loaded");
}
-(void) Bannerviewwillloadad: (Adbannerview *) banner{
    NSLog (@ "Ad'll Load");
}
-(void) Bannerviewactiondidfinish: (Adbannerview *) banner{
    NSLog (@ "Ad did finish");

}
@end
Output

Run the application and get the following output:


ii.inmobi Framework First, register InMobi account number, new advertising unit, waiting for audit.

1 registered account, registered address is: http://www.inmobi.com/, after registration, you need to fill out contact information and collect information, you can fill out the normal, InMobi support PayPal and telegraphic transfer, the author tried to make the Employment line card (dual-currency card, Generally new cards are supported) and PayPal can normally receive money, U.S. dollars Oh, hehe.

2 new ad unit, as shown below, if your app is online, enter app URL directly, or if app is developing, you can choose "No" and enter the app name. When finished, an ID will be generated, such as "4028cbff36f39ce201dfsdfsdfsdf2642", which will be used below.

3 new ads, when your app through the Apple Audit, to the app URL entry, let InMobi audit, otherwise can not display ads normally.


Second, access InMobi AD SDK to the project

From the downloaded SDK bundle, copy the following header file and binaries to the project. LIBINMOBI-5.X.X.A IMSdk.h IMBanner.h IMBannerDelegate.h IMInterstitial.h IMInterstitialDelegate.h IMNativeDelegate.h IMCustomNative.h IMRequestStatus.h IMCommonConstants.h
Add Frame

Add the following framework to your Xcode project: adsupport.framework audiotoolbox.framework avfoundation.framework corelocation.framework Coretelephony.framework eventkit.framework eventkitui.framework mediaplayer.framework MessageUI.framework Security.framework social.framework storekit.framework systemconfiguration.framework UIKit.framework Uikit.framework Libsqlite3.0.dylib Libc++.dylib

Note: Set the nslocationwheninuseusagedescription tag in the info.plist file to Yes;

Add additional version settings
Add tags to other linker tags to load all classes when the category is used. To complete this operation, complete the following steps:

1. Open the project in Xcode.
2. Select Application target > Version settings.
3. In the search field, search for "other linker tags."

4. Add-OBJC tags.
For iOS Application 9 Application transfer Security (ATS) is a new iOS9 default setting. It requires the application to make the network connection only in the TLS version. 1.2 and above. To ensure that all display ads are correctly displayed in your application, we are currently working with all our partners to ensure that 100% meets ATS requirements. Important: In this transition phase, however, please disable ATS for iOS 9 to ensure that display ads are properly built deisplay. This will reduce the impact of the American Thoracic Association on the application of monetization. Click here for more information. Disable ATS, add the following code fragment to the plist of your application.

<key>NSAppTransportSecurity</key> <dict> <key>NSAllowsArbitraryLoads</key> <true /> </dict> start Access to project Initialize SDK Import header file in AppDelegate.h

#import "IMSdk.h"
#import "IMCommonConstants.h"


Add an initialization method to the APPDELEGATE.M.

-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (Nsdictionary *) launchOptions {// Initialize InMobi SDK with your account ID
[Imsdk initwithaccountid:@ "fill in the ID of your application here is similar to the" SFHSJAHS2FHSJKHFKS2DFHKJ3F2 "note. Not that digital ID "];

Do your stuff.

return YES;

}

To popularize a little knowledge here.

Imbanner belongs to a banner ad

Iminterstitial belongs to an inset ad

imnative belong to the original advertisement

each corresponding method in the official document will have a corresponding method to create

I'm accessing a imnative this way of advertising. self.nativead=[[imnative alloc] initwithplacementid:@ "Insert native placement ID here"]; Self.nativead.delegate= self; [Self.nativead load]; One of the important attributes is that adcontent, which represents the content of the ad, is a JSON-formatted string. Inside the ImageUrl is you want to display the advertisement content, Loadurl is the advertisement link, these to you handles the advertisement the logic is very important oh [imnative bindNative:self.nativeView Toview:cell]; This method is used to bind your ad and the corresponding view must be run after the ad is fully displayed so that there is no false exposure. There are two ways of advertising jump, 1, [self.native Reportadclick: "Here incoming you loaded to the content of the advertisement self.native. " adcontent "];

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.