如何集成inmobi到ios
来源:互联网 发布:麦克雷爆头伤害数据 编辑:程序博客网 时间:2024/06/06 09:00
1 、Adding SDK to your project
Copy the below header files and binary from the downloaded SDK bundle to your project
libInMobi5.x.x.a
IMSdk.h
IMBanner.h
IMBannerDelegate.h
IMInterstitial.h
IMInterstitialDelegate.h
IMNative.h
IMNativeDelegate.h
IMCustomNative.h
IMRequestStatus.h
IMCommonConstants.h
2、Adding Frameworks
Add the frameworks below to your Xcode project by navigating to your project settings and hitting the “+” button under the “Linked Frameworks and Libraries” section.
AdSupport.framework
AudioToolbox.framework
AVFoundation.framework
CoreLocation.framework
CoreTelephony.framework
EventKit.framework
EventKitUI.framework
MediaPlayer.framework
MessageUI.framework
SafariServices.framework
Security.framework
Social.framework
StoreKit.framework
SystemConfiguration.framework
libsqlite3.0.dylib
libz.dylib
Note: If you use iOS 8.x, please add the
NSLocationWhenInUseUsageDescription
flag to your info.plist
file3、Adding Additional Build Settings
Add the
-ObjC
flag to Other Linker Flags by following the below steps:- Open your project in XCode
- Select Application Target > Build Settings
- In the Search field, search for Other Linker Flags
- Add the <code>-ObjC</code> flag
Also for now, disable ATS for apps on iOS 9 (Click here to learn why), and please add the following code snippet to your app's plist.
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
4、Initializing the InMobi SDK
You must initialize the SDK during app launch. Your account ID has been prepopulated to aid copying and pasting.
In AppDelegate.h
, import the below:
#import "IMCommonConstants.h"
In the
UIViewController.h
file that reflects the location of your ad unit, import the below:#import "IMBanner.h"
#import "IMBannerDelegate.h"
#import "IMInterstitial.h"
#import "IMInterstitialDelegate.h"
#import "IMNative.h"
#import "IMNativeDelegate.h"
#import "IMBannerDelegate.h"
#import "IMInterstitial.h"
#import "IMInterstitialDelegate.h"
#import "IMNative.h"
#import "IMNativeDelegate.h"
In
AppDelegate.m
file, didFinishLaunchingWithOptions
method, initialize the SDK as shown below:- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//Initialize InMobi SDK with your account ID
[IMSdk initWithAccountID:@"9697f54927be4ff3ba71a02181323d65"];
// Do your stuff.
return YES;
}
//Initialize InMobi SDK with your account ID
[IMSdk initWithAccountID:@"9697f54927be4ff3ba71a02181323d65"];
// Do your stuff.
return YES;
}
5、Implementing a Full Screen Interstitial Ad
InMobi serves both landscape and portrait type of interstitial ads (non-rewarded video, images, rich-media). The InMobi SDK will automatically ensure that it serves appropriate ads as per the application orientation. Perform the below steps to implement interstitial ads.
- Register the
UIViewController
with <IMInterstitialDelegate> and declare an interstitial instance as shown below before@end
of your declaration section . Make any necessary code changes to avoid duplication of controller definitions.
@property (nonatomic,strong) IMInterstitial *interstitial;
2.To instantiate your interstitial, copy and paste the below code in the
viewDidLoad()
method of your UIViewController
or in a method that initiates a new user session in order to enable loading of the ad./* This code loads the ad in the cache for better performance. Please place this in a method of your controller that ensure that ads are loaded again after they have been dismissed. */
self.interstitial = [[IMInterstitial alloc] initWithPlacementId:1449126032215 delegate:self];
[self.interstitial load];
self.interstitial = [[IMInterstitial alloc] initWithPlacementId:1449126032215 delegate:self];
[self.interstitial load];
3.Add the following callbacks by copying the below code and pasting it in your
UIViewController
before the last @end
line.- (void)interstitial:(IMInterstitial *)interstitial didFailToLoadWithError:(IMRequestStatus *)error{
NSLog(@"Interstitial Failed to load interstitial with error: %@",error.description);
}
- (void)interstitial:(IMInterstitial *)interstitial didFailToPresentWithError:(IMRequestStatus *)error {
NSLog(@"Interstitial Failed to Present Interstitial with error : %@",error.description);
}
- (void)interstitial:(IMInterstitial *)interstitial didInteractWithParams:(NSDictionary *)params {
NSLog(@"Interstitial did interact with param : %@",params);
}
- (void)interstitial:(IMInterstitial *)interstitial rewardActionCompletedWithRewards:(NSDictionary *)rewards {
NSLog(@"Interstitial reward action completed with Rewards : %@",rewards);
}
- (void)interstitialDidDismiss:(IMInterstitial *)interstitial {
NSLog(@"Interstitial Did Dismiss");
}
- (void)interstitialDidFinishLoading:(IMInterstitial *)interstitial {
NSLog(@"Interstitial Did Finish Loading");
}
- (void)interstitialDidPresent:(IMInterstitial *)interstitial {
NSLog(@"Interstitial Did Present");
}
- (void)interstitialWillDismiss:(IMInterstitial *)interstitial {
NSLog(@"Interstitial Will Dismiss");
}
- (void)interstitialWillPresent:(IMInterstitial *)interstitial {
NSLog(@"Interstitial Will Present");
}
NSLog(@"Interstitial Failed to load interstitial with error: %@",error.description);
}
- (void)interstitial:(IMInterstitial *)interstitial didFailToPresentWithError:(IMRequestStatus *)error {
NSLog(@"Interstitial Failed to Present Interstitial with error : %@",error.description);
}
- (void)interstitial:(IMInterstitial *)interstitial didInteractWithParams:(NSDictionary *)params {
NSLog(@"Interstitial did interact with param : %@",params);
}
- (void)interstitial:(IMInterstitial *)interstitial rewardActionCompletedWithRewards:(NSDictionary *)rewards {
NSLog(@"Interstitial reward action completed with Rewards : %@",rewards);
}
- (void)interstitialDidDismiss:(IMInterstitial *)interstitial {
NSLog(@"Interstitial Did Dismiss");
}
- (void)interstitialDidFinishLoading:(IMInterstitial *)interstitial {
NSLog(@"Interstitial Did Finish Loading");
}
- (void)interstitialDidPresent:(IMInterstitial *)interstitial {
NSLog(@"Interstitial Did Present");
}
- (void)interstitialWillDismiss:(IMInterstitial *)interstitial {
NSLog(@"Interstitial Will Dismiss");
}
- (void)interstitialWillPresent:(IMInterstitial *)interstitial {
NSLog(@"Interstitial Will Present");
}
4.Add the following code to a method in your controller that is invoked at the time at which you want the ad to be shown. This is typically at level failure in a game, or as an item in the store-front or so on.
if ([self.interstitial isReady]){
[self.interstitial showFromViewController:self];
}
[self.interstitial showFromViewController:self];
}
0 0
- 如何集成inmobi到ios
- 如何集成inmobi到ios
- 如何集成inmobi到android
- iOS-插入广告-InMobi使用教程
- Inmobi:中国App如何挑战全球?
- weex 集成到iOS
- iOS开发 接入InMobi广告平台的一些个人经验
- 多平台开发 JavaScript 接入ios原生 inMobi 广告
- IOS集成到支付宝
- ios-如何集成支付宝
- iOS- 如何集成支付宝
- iOS- 如何集成支付宝
- iOS如何集成支付宝
- iOS- 如何集成支付宝
- iOS如何集成支付宝
- iOS如何集成支付宝
- iOS 如何集成支付宝
- iOS- 如何集成支付宝
- 常用易混方法及其参数
- OC中字典基本用法
- 博客系统要点的一些回顾
- [LeetCode]Binary Tree Zigzag Level Order Traversal
- PhoneGap/Cordova学习笔记--1.Android环境搭建
- 如何集成inmobi到ios
- c++中vector的用法详解
- [Android教程] Android系统Intent中的Uri使用
- C++学习:初识类
- 卸载iSCSI磁盘阵列
- iOS中的手势详解
- http://blog.sina.com.cn/s/blog_ad1c3bdf0102uz99.html
- git 使用常见问题汇总
- Swift 基础语法