diff --git a/Docs/Getting_Started.md b/Docs/Getting_Started.md new file mode 100644 index 0000000..f2a162f --- /dev/null +++ b/Docs/Getting_Started.md @@ -0,0 +1,123 @@ +# 舜飞广告 iOS SDK 1.x 开发文档 + +## 开发环境 + +* Xcode 7.0 或更高版本 +* 支持 iOS 6.0.0 或更高版本 + +## PublisherID、PlacementID、AppID + +从 [官网](http://mbv.biddingx.com/main/) 获取 PublisherID、PlacementID、AppID。 + +## SDK 集成 + +1、将最新的 SDK 头文件 `SuntengMobileAdsSDK.h` 、 `STMInterstitialAdController.h` 和静态库 `libSuntengMobileAdsSDK.a` 加入项目中。 + +2、添加需要的 Framework: + +```objc +AdSupport.framework +CoreFoundation.framework +CoreGraphics.framework +CoreLocation.framework +CoreTelephony.framework +Foundation.framework +SystemConfiguration.framework +UIKit.framework +``` + +3、设置对应 **target** 的编译选项,在『Build Settings』->『Linking』->『Other Linker Flags』,添加 `-ObjC` 参数。 + +4、iOS 8.0+ 中获取地理位置方法,在 info.plist 里加入对应的定位请求字段,值可以为空或者填写获取定位请求提示框要显示的内容。 + +```objc +NSLocationWhenInUseUsageDescription // 允许在前台获取GPS的描述 +``` + +**说明:由于部分广告会定向投递到某些城市,SDK 需要获取地理位置以支持广告的定向投放。** + +5、Xcode 7.0+ 、iOS 9.0+ 适配 + +* 关于 [*ATS*](https://developer.apple.com/library/prerelease/ios/technotes/App-Transport-Security-Technote/index.html#//apple_ref/doc/uid/TP40016240) + + **解决方案:禁用 ATS。** + + 在应用的 Info.plist 中添加禁用 ATS 代码。代码如下: + +```XML +NSAppTransportSecurity + + NSAllowsArbitraryLoads + + +``` + +* 关于 Bitcode + + Xcode 7.0 默认开启 **Bitcode** 编译选项(无 **Bitcode** 配置,默认为开启), SDK 1.0.0+ 版本开始支持 **Bitcode** ,如果您的工程中有其它不支持 **Bitcode** 特性的库可能编译不过。 + + **解决方案:请将项目对应『Target』->『Build Settings』->『Build Options』->『Enable Bitcode』选项设置为 No 。** + +## SDK 使用 + +### 初始化 SDK + +```objc +#import "SuntengMobileAdsSDK.h" + +@interface ViewController () + +@property(nonatomic, weak) STMInterstitialAdController *interstitialAdController; + +@end + +@implementation ViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + + self.interstitialAdController = [STMInterstitialAdController interstitialAdControllerWithPublishedId:@"1" + appId:@"2" + placementId:@"3"]; +} + +@end +``` + +### 展示插屏广告 + +当您需要展示插屏广告时,请在尝试展示之前检查它是否已准备就绪。 + +```objc +if (self.interstitialAdController.isLoaded) { + [self.interstitialAdController presentFromViewController:self]; +} +``` + +### 跟踪广告生命周期 + +您可以通过实现 `STMInterstitialAdControllerDelegate ` 中定义的协议,来跟踪广告生命周期中的各个阶段。所有方法定义如下: + +```objc +@protocol STMInterstitialAdControllerDelegate + +@optional + +// 当插屏广告被成功加载后,回调该方法 +- (void)interstitialDidLoad:(STMInterstitialAdController *)interstitial; + +// 当插屏广告加载失败后,回调该方法 +- (void)interstitialDidLoadFail:(STMInterstitialAdController *)interstitial; + +// 当插屏广告展示出来时,回调该方法 +- (void)interstitialDidPresent:(STMInterstitialAdController *)interstitial; + +// 当用户点击广告,回调该方法 +- (void)interstitialDidTap:(STMInterstitialAdController *)interstitial; + +// 当插屏广告被关闭后,回调该方法 +- (void)interstitialDidDismiss:(STMInterstitialAdController *)interstitial; + +@end +``` + diff --git "a/Docs/\350\210\234\351\243\236\347\247\273\345\212\250\345\271\277\345\221\212SDK\345\274\200\345\217\221\346\226\207\346\241\243.html" "b/Docs/\350\210\234\351\243\236\347\247\273\345\212\250\345\271\277\345\221\212SDK\345\274\200\345\217\221\346\226\207\346\241\243.html" new file mode 100644 index 0000000..cc2dc1e --- /dev/null +++ "b/Docs/\350\210\234\351\243\236\347\247\273\345\212\250\345\271\277\345\221\212SDK\345\274\200\345\217\221\346\226\207\346\241\243.html" @@ -0,0 +1,314 @@ + + + + + + GettingStarted + + + + + + + + +
+

舜飞广告 iOS SDK 1.x 开发文档

+ +

开发环境

+ + + + +

PublisherID、PlacementID、AppID

+ +

官网 获取 PublisherID、PlacementID、AppID。

+ +

SDK 集成

+ +

1、将最新的 SDK 头文件 SuntengMobileAdsSDK.hSTMInterstitialAdController.h 和静态库 libSuntengMobileAdsSDK.a 加入项目中。

+ +

2、添加需要的 Framework:

+ +
AdSupport.framework
+CoreFoundation.framework
+CoreGraphics.framework
+CoreLocation.framework
+CoreTelephony.framework
+Foundation.framework
+SystemConfiguration.framework
+UIKit.framework
+ + +

3、设置对应 target 的编译选项,在『Build Settings』->『Linking』->『Other Linker Flags』,添加 -ObjC 参数。

+ +

4、iOS 8.0+ 中获取地理位置方法,在 info.plist 里加入对应的定位请求字段,值可以为空或者填写获取定位请求提示框要显示的内容。

+ +
NSLocationWhenInUseUsageDescription   // 允许在前台获取GPS的描述
+ + +

说明:由于部分广告会定向投递到某些城市,SDK 需要获取地理位置以支持广告的定向投放。

+ +

5、Xcode 7.0+ 、iOS 9.0+ 适配

+ + + + +
<key>NSAppTransportSecurity</key>
+<dict>
+	<key>NSAllowsArbitraryLoads</key>
+	<true/>
+</dict>
+ + + + + +

SDK 使用

+ +

初始化 SDK

+ +
#import "SuntengMobileAdsSDK.h"
+
+@interface ViewController ()
+
+@property(nonatomic, weak) STMInterstitialAdController *interstitialAdController;
+
+@end
+
+@implementation ViewController
+
+- (void)viewDidLoad {
+    [super viewDidLoad];
+    
+    self.interstitialAdController = [STMInterstitialAdController interstitialAdControllerWithPublishedId:@"1"
+                                                                                                   appId:@"2"
+                                                                                             placementId:@"3"];
+}
+
+@end
+ + +

展示插屏广告

+ +

当您需要展示插屏广告时,请在尝试展示之前检查它是否已准备就绪。

+ +
if (self.interstitialAdController.isLoaded) {
+	[self.interstitialAdController presentFromViewController:self];
+} 
+ + +

跟踪广告生命周期

+ +

您可以通过实现 STMInterstitialAdControllerDelegate 中定义的协议,来跟踪广告生命周期中的各个阶段。所有方法定义如下:

+ +
@protocol STMInterstitialAdControllerDelegate <NSObject>
+
+@optional
+
+// 当插屏广告被成功加载后,回调该方法
+- (void)interstitialDidLoad:(STMInterstitialAdController *)interstitial;
+
+// 当插屏广告加载失败后,回调该方法
+- (void)interstitialDidLoadFail:(STMInterstitialAdController *)interstitial;
+
+// 当插屏广告展示出来时,回调该方法
+- (void)interstitialDidPresent:(STMInterstitialAdController *)interstitial;
+
+// 当用户点击广告,回调该方法
+- (void)interstitialDidTap:(STMInterstitialAdController *)interstitial;
+
+// 当插屏广告被关闭后,回调该方法
+- (void)interstitialDidDismiss:(STMInterstitialAdController *)interstitial;
+
+@end
+ + + + +
+ + + +
+ + + + + + + +
+ + \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..a7d0f60 --- /dev/null +++ b/README.md @@ -0,0 +1,12 @@ +# suntengMob-sdk-ios for iOS + +移动广告 SDK + +## 如何使用 + +- [Getting Started with SDK](https://github.com/shunfei/suntengMob-sdk-ios/blob/master/Docs/Getting_Started.md) + +## Change Log +04/22/2016 - v1.0.0 + +* initial release diff --git a/STMobSDK/STMInterstitialAdController.h b/STMobSDK/STMInterstitialAdController.h new file mode 100644 index 0000000..5513aa3 --- /dev/null +++ b/STMobSDK/STMInterstitialAdController.h @@ -0,0 +1,73 @@ +// +// STMInterstitialAdController.h +// SuntengMobileAdsSDK +// +// Created by Joe. +// Copyright © 2016年 Sunteng Information Technology Co., Ltd. All rights reserved. +// + +#import + +@protocol STMInterstitialAdControllerDelegate; + +@interface STMInterstitialAdController : UIViewController + +/** + * Create and return a `STMInterstitialAdController` instance + * + * @param adUnitID The ad unit ID + * + * @return A `STMInterstitialAdController` instance + */ ++ (instancetype)interstitialAdControllerWithPublishedId:(NSString *)publishedId + appId:(NSString *)appId + placementId:(NSString *)placementId; + +/** + * The ad unit ID + */ +@property (nonatomic, copy, readonly) NSString *adUnitID; + +/** + * `STMInterstitialAdController` delegate + */ +@property (nonatomic, weak) id delegate; + +/** + * Load ad + */ +- (void)loadAd; + +/** + * check is ad loaded and ready to show + */ +@property (nonatomic, assign, readonly, getter=isLoaded) BOOL loaded; + +/** + * Present ad from the given controller + * + * @param controller Ad present from this controller + */ +- (void)presentFromViewController:(UIViewController *)controller; + +@end + +///------------------------------------------ +/// @name STMInterstitialAdControllerDelegate +///------------------------------------------ + +@protocol STMInterstitialAdControllerDelegate + +@optional + +- (void)interstitialDidLoad:(STMInterstitialAdController *)interstitial; + +- (void)interstitialDidLoadFail:(STMInterstitialAdController *)interstitial; + +- (void)interstitialDidPresent:(STMInterstitialAdController *)interstitial; + +- (void)interstitialDidTap:(STMInterstitialAdController *)interstitial; + +- (void)interstitialDidDismiss:(STMInterstitialAdController *)interstitial; + +@end diff --git a/STMobSDK/SuntengMobileAdsSDK.h b/STMobSDK/SuntengMobileAdsSDK.h new file mode 100644 index 0000000..8744325 --- /dev/null +++ b/STMobSDK/SuntengMobileAdsSDK.h @@ -0,0 +1,30 @@ +// +// SuntengMobileAdsSDK.h +// SuntengMobileAdsSDK +// +// Created by Joe. +// Copyright © 2016年 Sunteng Information Technology Co., Ltd. All rights reserved. +// + +#import +#import "STMInterstitialAdController.h" + +NS_ASSUME_NONNULL_BEGIN + +/** + * Sunteng mobile ad SDK version. + */ +extern NSString * const STMAdsSDKVersion; + +@interface SuntengMobileAdsSDK : NSObject + +/** + * The sunteng mobile ads SDK singleton object. + * + * @return The sunteng mobile ads SDK singleton object. + */ ++ (instancetype)sharedInstance; + +@end + +NS_ASSUME_NONNULL_END diff --git a/STMobSDK/libSuntengMobileAdsSDK.a b/STMobSDK/libSuntengMobileAdsSDK.a new file mode 100644 index 0000000..190f857 Binary files /dev/null and b/STMobSDK/libSuntengMobileAdsSDK.a differ diff --git a/STMobSDKSample/STMobSDKSample.xcodeproj/project.pbxproj b/STMobSDKSample/STMobSDKSample.xcodeproj/project.pbxproj new file mode 100644 index 0000000..4554e02 --- /dev/null +++ b/STMobSDKSample/STMobSDKSample.xcodeproj/project.pbxproj @@ -0,0 +1,379 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + C59E8F551CCA165200E4F152 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = C59E8F541CCA165200E4F152 /* main.m */; }; + C59E8F581CCA165200E4F152 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = C59E8F571CCA165200E4F152 /* AppDelegate.m */; }; + C59E8F5B1CCA165300E4F152 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C59E8F5A1CCA165300E4F152 /* ViewController.m */; }; + C59E8F5E1CCA165300E4F152 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C59E8F5C1CCA165300E4F152 /* Main.storyboard */; }; + C59E8F601CCA165300E4F152 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C59E8F5F1CCA165300E4F152 /* Assets.xcassets */; }; + C59E8F631CCA165300E4F152 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C59E8F611CCA165300E4F152 /* LaunchScreen.storyboard */; }; + C59E8F6E1CCA165B00E4F152 /* libSuntengMobileAdsSDK.a in Frameworks */ = {isa = PBXBuildFile; fileRef = C59E8F6B1CCA165B00E4F152 /* libSuntengMobileAdsSDK.a */; }; + C59E8F711CCA1A2300E4F152 /* AdSupport.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C59E8F701CCA1A2300E4F152 /* AdSupport.framework */; }; + C59E8F731CCA1A2A00E4F152 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C59E8F721CCA1A2A00E4F152 /* CoreFoundation.framework */; }; + C59E8F751CCA1A3000E4F152 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C59E8F741CCA1A3000E4F152 /* CoreGraphics.framework */; }; + C59E8F771CCA1A3B00E4F152 /* CoreLocation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C59E8F761CCA1A3B00E4F152 /* CoreLocation.framework */; }; + C59E8F791CCA1A4100E4F152 /* CoreTelephony.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C59E8F781CCA1A4100E4F152 /* CoreTelephony.framework */; }; + C59E8F7B1CCA1A4900E4F152 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C59E8F7A1CCA1A4900E4F152 /* Foundation.framework */; }; + C59E8F7D1CCA1A4F00E4F152 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C59E8F7C1CCA1A4F00E4F152 /* SystemConfiguration.framework */; }; + C59E8F7F1CCA1A5500E4F152 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C59E8F7E1CCA1A5500E4F152 /* UIKit.framework */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + C59E8F501CCA165200E4F152 /* STMobSDKSample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = STMobSDKSample.app; sourceTree = BUILT_PRODUCTS_DIR; }; + C59E8F541CCA165200E4F152 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + C59E8F561CCA165200E4F152 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; + C59E8F571CCA165200E4F152 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; + C59E8F591CCA165300E4F152 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; + C59E8F5A1CCA165300E4F152 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; + C59E8F5D1CCA165300E4F152 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + C59E8F5F1CCA165300E4F152 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + C59E8F621CCA165300E4F152 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + C59E8F641CCA165300E4F152 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + C59E8F6B1CCA165B00E4F152 /* libSuntengMobileAdsSDK.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libSuntengMobileAdsSDK.a; sourceTree = ""; }; + C59E8F6C1CCA165B00E4F152 /* STMInterstitialAdController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = STMInterstitialAdController.h; sourceTree = ""; }; + C59E8F6D1CCA165B00E4F152 /* SuntengMobileAdsSDK.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SuntengMobileAdsSDK.h; sourceTree = ""; }; + C59E8F701CCA1A2300E4F152 /* AdSupport.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AdSupport.framework; path = System/Library/Frameworks/AdSupport.framework; sourceTree = SDKROOT; }; + C59E8F721CCA1A2A00E4F152 /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = System/Library/Frameworks/CoreFoundation.framework; sourceTree = SDKROOT; }; + C59E8F741CCA1A3000E4F152 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; + C59E8F761CCA1A3B00E4F152 /* CoreLocation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreLocation.framework; path = System/Library/Frameworks/CoreLocation.framework; sourceTree = SDKROOT; }; + C59E8F781CCA1A4100E4F152 /* CoreTelephony.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreTelephony.framework; path = System/Library/Frameworks/CoreTelephony.framework; sourceTree = SDKROOT; }; + C59E8F7A1CCA1A4900E4F152 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; + C59E8F7C1CCA1A4F00E4F152 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; }; + C59E8F7E1CCA1A5500E4F152 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + C59E8F4D1CCA165200E4F152 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + C59E8F7F1CCA1A5500E4F152 /* UIKit.framework in Frameworks */, + C59E8F7D1CCA1A4F00E4F152 /* SystemConfiguration.framework in Frameworks */, + C59E8F7B1CCA1A4900E4F152 /* Foundation.framework in Frameworks */, + C59E8F791CCA1A4100E4F152 /* CoreTelephony.framework in Frameworks */, + C59E8F771CCA1A3B00E4F152 /* CoreLocation.framework in Frameworks */, + C59E8F751CCA1A3000E4F152 /* CoreGraphics.framework in Frameworks */, + C59E8F731CCA1A2A00E4F152 /* CoreFoundation.framework in Frameworks */, + C59E8F711CCA1A2300E4F152 /* AdSupport.framework in Frameworks */, + C59E8F6E1CCA165B00E4F152 /* libSuntengMobileAdsSDK.a in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + C59E8F471CCA165200E4F152 = { + isa = PBXGroup; + children = ( + C59E8F521CCA165200E4F152 /* STMobSDKSample */, + C59E8F811CCA1A7900E4F152 /* Frameworks */, + C59E8F511CCA165200E4F152 /* Products */, + ); + sourceTree = ""; + }; + C59E8F511CCA165200E4F152 /* Products */ = { + isa = PBXGroup; + children = ( + C59E8F501CCA165200E4F152 /* STMobSDKSample.app */, + ); + name = Products; + sourceTree = ""; + }; + C59E8F521CCA165200E4F152 /* STMobSDKSample */ = { + isa = PBXGroup; + children = ( + C59E8F6A1CCA165B00E4F152 /* STMobSDK */, + C59E8F561CCA165200E4F152 /* AppDelegate.h */, + C59E8F571CCA165200E4F152 /* AppDelegate.m */, + C59E8F591CCA165300E4F152 /* ViewController.h */, + C59E8F5A1CCA165300E4F152 /* ViewController.m */, + C59E8F5C1CCA165300E4F152 /* Main.storyboard */, + C59E8F5F1CCA165300E4F152 /* Assets.xcassets */, + C59E8F611CCA165300E4F152 /* LaunchScreen.storyboard */, + C59E8F641CCA165300E4F152 /* Info.plist */, + C59E8F531CCA165200E4F152 /* Supporting Files */, + ); + path = STMobSDKSample; + sourceTree = ""; + }; + C59E8F531CCA165200E4F152 /* Supporting Files */ = { + isa = PBXGroup; + children = ( + C59E8F541CCA165200E4F152 /* main.m */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; + C59E8F6A1CCA165B00E4F152 /* STMobSDK */ = { + isa = PBXGroup; + children = ( + C59E8F6B1CCA165B00E4F152 /* libSuntengMobileAdsSDK.a */, + C59E8F6C1CCA165B00E4F152 /* STMInterstitialAdController.h */, + C59E8F6D1CCA165B00E4F152 /* SuntengMobileAdsSDK.h */, + ); + path = STMobSDK; + sourceTree = ""; + }; + C59E8F811CCA1A7900E4F152 /* Frameworks */ = { + isa = PBXGroup; + children = ( + C59E8F7E1CCA1A5500E4F152 /* UIKit.framework */, + C59E8F7C1CCA1A4F00E4F152 /* SystemConfiguration.framework */, + C59E8F7A1CCA1A4900E4F152 /* Foundation.framework */, + C59E8F781CCA1A4100E4F152 /* CoreTelephony.framework */, + C59E8F761CCA1A3B00E4F152 /* CoreLocation.framework */, + C59E8F741CCA1A3000E4F152 /* CoreGraphics.framework */, + C59E8F721CCA1A2A00E4F152 /* CoreFoundation.framework */, + C59E8F701CCA1A2300E4F152 /* AdSupport.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + C59E8F4F1CCA165200E4F152 /* STMobSDKSample */ = { + isa = PBXNativeTarget; + buildConfigurationList = C59E8F671CCA165300E4F152 /* Build configuration list for PBXNativeTarget "STMobSDKSample" */; + buildPhases = ( + C59E8F4C1CCA165200E4F152 /* Sources */, + C59E8F4D1CCA165200E4F152 /* Frameworks */, + C59E8F4E1CCA165200E4F152 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = STMobSDKSample; + productName = STMobSDKSample; + productReference = C59E8F501CCA165200E4F152 /* STMobSDKSample.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + C59E8F481CCA165200E4F152 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0720; + ORGANIZATIONNAME = sunteng; + TargetAttributes = { + C59E8F4F1CCA165200E4F152 = { + CreatedOnToolsVersion = 7.2; + }; + }; + }; + buildConfigurationList = C59E8F4B1CCA165200E4F152 /* Build configuration list for PBXProject "STMobSDKSample" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = C59E8F471CCA165200E4F152; + productRefGroup = C59E8F511CCA165200E4F152 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + C59E8F4F1CCA165200E4F152 /* STMobSDKSample */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + C59E8F4E1CCA165200E4F152 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + C59E8F631CCA165300E4F152 /* LaunchScreen.storyboard in Resources */, + C59E8F601CCA165300E4F152 /* Assets.xcassets in Resources */, + C59E8F5E1CCA165300E4F152 /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + C59E8F4C1CCA165200E4F152 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + C59E8F5B1CCA165300E4F152 /* ViewController.m in Sources */, + C59E8F581CCA165200E4F152 /* AppDelegate.m in Sources */, + C59E8F551CCA165200E4F152 /* main.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + C59E8F5C1CCA165300E4F152 /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + C59E8F5D1CCA165300E4F152 /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + C59E8F611CCA165300E4F152 /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + C59E8F621CCA165300E4F152 /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + C59E8F651CCA165300E4F152 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 9.2; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + C59E8F661CCA165300E4F152 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 9.2; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + C59E8F681CCA165300E4F152 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_IDENTITY = "iPhone Developer"; + INFOPLIST_FILE = STMobSDKSample/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 6.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/STMobSDKSample/STMobSDK", + ); + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_BUNDLE_IDENTIFIER = com.sunteng.com.STMobSDKSample; + PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE = ""; + }; + name = Debug; + }; + C59E8F691CCA165300E4F152 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_IDENTITY = "iPhone Developer"; + INFOPLIST_FILE = STMobSDKSample/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 6.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/STMobSDKSample/STMobSDK", + ); + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_BUNDLE_IDENTIFIER = com.sunteng.com.STMobSDKSample; + PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE = ""; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + C59E8F4B1CCA165200E4F152 /* Build configuration list for PBXProject "STMobSDKSample" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + C59E8F651CCA165300E4F152 /* Debug */, + C59E8F661CCA165300E4F152 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + C59E8F671CCA165300E4F152 /* Build configuration list for PBXNativeTarget "STMobSDKSample" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + C59E8F681CCA165300E4F152 /* Debug */, + C59E8F691CCA165300E4F152 /* Release */, + ); + defaultConfigurationIsVisible = 0; + }; +/* End XCConfigurationList section */ + }; + rootObject = C59E8F481CCA165200E4F152 /* Project object */; +} diff --git a/STMobSDKSample/STMobSDKSample.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/STMobSDKSample/STMobSDKSample.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..b0e9c7a --- /dev/null +++ b/STMobSDKSample/STMobSDKSample.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/STMobSDKSample/STMobSDKSample.xcodeproj/project.xcworkspace/xcuserdata/east.xcuserdatad/UserInterfaceState.xcuserstate b/STMobSDKSample/STMobSDKSample.xcodeproj/project.xcworkspace/xcuserdata/east.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000..c7d97f6 Binary files /dev/null and b/STMobSDKSample/STMobSDKSample.xcodeproj/project.xcworkspace/xcuserdata/east.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/STMobSDKSample/STMobSDKSample.xcodeproj/xcuserdata/east.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/STMobSDKSample/STMobSDKSample.xcodeproj/xcuserdata/east.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist new file mode 100644 index 0000000..fe2b454 --- /dev/null +++ b/STMobSDKSample/STMobSDKSample.xcodeproj/xcuserdata/east.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -0,0 +1,5 @@ + + + diff --git a/STMobSDKSample/STMobSDKSample.xcodeproj/xcuserdata/east.xcuserdatad/xcschemes/STMobSDKSample.xcscheme b/STMobSDKSample/STMobSDKSample.xcodeproj/xcuserdata/east.xcuserdatad/xcschemes/STMobSDKSample.xcscheme new file mode 100644 index 0000000..4c33b10 --- /dev/null +++ b/STMobSDKSample/STMobSDKSample.xcodeproj/xcuserdata/east.xcuserdatad/xcschemes/STMobSDKSample.xcscheme @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/STMobSDKSample/STMobSDKSample.xcodeproj/xcuserdata/east.xcuserdatad/xcschemes/xcschememanagement.plist b/STMobSDKSample/STMobSDKSample.xcodeproj/xcuserdata/east.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 0000000..42bd5ca --- /dev/null +++ b/STMobSDKSample/STMobSDKSample.xcodeproj/xcuserdata/east.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,22 @@ + + + + + SchemeUserState + + STMobSDKSample.xcscheme + + orderHint + 0 + + + SuppressBuildableAutocreation + + C59E8F4F1CCA165200E4F152 + + primary + + + + + diff --git a/STMobSDKSample/STMobSDKSample/AppDelegate.h b/STMobSDKSample/STMobSDKSample/AppDelegate.h new file mode 100644 index 0000000..be155c2 --- /dev/null +++ b/STMobSDKSample/STMobSDKSample/AppDelegate.h @@ -0,0 +1,17 @@ +// +// AppDelegate.h +// STMobSDKSample +// +// Created by East on 16/4/22. +// Copyright © 2016年 sunteng. All rights reserved. +// + +#import + +@interface AppDelegate : UIResponder + +@property (strong, nonatomic) UIWindow *window; + + +@end + diff --git a/STMobSDKSample/STMobSDKSample/AppDelegate.m b/STMobSDKSample/STMobSDKSample/AppDelegate.m new file mode 100644 index 0000000..07bc913 --- /dev/null +++ b/STMobSDKSample/STMobSDKSample/AppDelegate.m @@ -0,0 +1,45 @@ +// +// AppDelegate.m +// STMobSDKSample +// +// Created by East on 16/4/22. +// Copyright © 2016年 sunteng. All rights reserved. +// + +#import "AppDelegate.h" + +@interface AppDelegate () + +@end + +@implementation AppDelegate + + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + // Override point for customization after application launch. + return YES; +} + +- (void)applicationWillResignActive:(UIApplication *)application { + // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. + // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. +} + +- (void)applicationDidEnterBackground:(UIApplication *)application { + // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. + // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. +} + +- (void)applicationWillEnterForeground:(UIApplication *)application { + // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. +} + +- (void)applicationDidBecomeActive:(UIApplication *)application { + // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. +} + +- (void)applicationWillTerminate:(UIApplication *)application { + // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. +} + +@end diff --git a/STMobSDKSample/STMobSDKSample/Assets.xcassets/AppIcon.appiconset/Contents.json b/STMobSDKSample/STMobSDKSample/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..36d2c80 --- /dev/null +++ b/STMobSDKSample/STMobSDKSample/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,68 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "3x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/STMobSDKSample/STMobSDKSample/Base.lproj/LaunchScreen.storyboard b/STMobSDKSample/STMobSDKSample/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000..2e721e1 --- /dev/null +++ b/STMobSDKSample/STMobSDKSample/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/STMobSDKSample/STMobSDKSample/Base.lproj/Main.storyboard b/STMobSDKSample/STMobSDKSample/Base.lproj/Main.storyboard new file mode 100644 index 0000000..b4baf08 --- /dev/null +++ b/STMobSDKSample/STMobSDKSample/Base.lproj/Main.storyboard @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/STMobSDKSample/STMobSDKSample/Info.plist b/STMobSDKSample/STMobSDKSample/Info.plist new file mode 100644 index 0000000..028efc3 --- /dev/null +++ b/STMobSDKSample/STMobSDKSample/Info.plist @@ -0,0 +1,52 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + LSRequiresIPhoneOS + + NSAppTransportSecurity + + NSAllowsArbitraryLoads + + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/STMobSDKSample/STMobSDKSample/STMobSDK/STMInterstitialAdController.h b/STMobSDKSample/STMobSDKSample/STMobSDK/STMInterstitialAdController.h new file mode 100644 index 0000000..5513aa3 --- /dev/null +++ b/STMobSDKSample/STMobSDKSample/STMobSDK/STMInterstitialAdController.h @@ -0,0 +1,73 @@ +// +// STMInterstitialAdController.h +// SuntengMobileAdsSDK +// +// Created by Joe. +// Copyright © 2016年 Sunteng Information Technology Co., Ltd. All rights reserved. +// + +#import + +@protocol STMInterstitialAdControllerDelegate; + +@interface STMInterstitialAdController : UIViewController + +/** + * Create and return a `STMInterstitialAdController` instance + * + * @param adUnitID The ad unit ID + * + * @return A `STMInterstitialAdController` instance + */ ++ (instancetype)interstitialAdControllerWithPublishedId:(NSString *)publishedId + appId:(NSString *)appId + placementId:(NSString *)placementId; + +/** + * The ad unit ID + */ +@property (nonatomic, copy, readonly) NSString *adUnitID; + +/** + * `STMInterstitialAdController` delegate + */ +@property (nonatomic, weak) id delegate; + +/** + * Load ad + */ +- (void)loadAd; + +/** + * check is ad loaded and ready to show + */ +@property (nonatomic, assign, readonly, getter=isLoaded) BOOL loaded; + +/** + * Present ad from the given controller + * + * @param controller Ad present from this controller + */ +- (void)presentFromViewController:(UIViewController *)controller; + +@end + +///------------------------------------------ +/// @name STMInterstitialAdControllerDelegate +///------------------------------------------ + +@protocol STMInterstitialAdControllerDelegate + +@optional + +- (void)interstitialDidLoad:(STMInterstitialAdController *)interstitial; + +- (void)interstitialDidLoadFail:(STMInterstitialAdController *)interstitial; + +- (void)interstitialDidPresent:(STMInterstitialAdController *)interstitial; + +- (void)interstitialDidTap:(STMInterstitialAdController *)interstitial; + +- (void)interstitialDidDismiss:(STMInterstitialAdController *)interstitial; + +@end diff --git a/STMobSDKSample/STMobSDKSample/STMobSDK/SuntengMobileAdsSDK.h b/STMobSDKSample/STMobSDKSample/STMobSDK/SuntengMobileAdsSDK.h new file mode 100644 index 0000000..8744325 --- /dev/null +++ b/STMobSDKSample/STMobSDKSample/STMobSDK/SuntengMobileAdsSDK.h @@ -0,0 +1,30 @@ +// +// SuntengMobileAdsSDK.h +// SuntengMobileAdsSDK +// +// Created by Joe. +// Copyright © 2016年 Sunteng Information Technology Co., Ltd. All rights reserved. +// + +#import +#import "STMInterstitialAdController.h" + +NS_ASSUME_NONNULL_BEGIN + +/** + * Sunteng mobile ad SDK version. + */ +extern NSString * const STMAdsSDKVersion; + +@interface SuntengMobileAdsSDK : NSObject + +/** + * The sunteng mobile ads SDK singleton object. + * + * @return The sunteng mobile ads SDK singleton object. + */ ++ (instancetype)sharedInstance; + +@end + +NS_ASSUME_NONNULL_END diff --git a/STMobSDKSample/STMobSDKSample/STMobSDK/libSuntengMobileAdsSDK.a b/STMobSDKSample/STMobSDKSample/STMobSDK/libSuntengMobileAdsSDK.a new file mode 100644 index 0000000..190f857 Binary files /dev/null and b/STMobSDKSample/STMobSDKSample/STMobSDK/libSuntengMobileAdsSDK.a differ diff --git a/STMobSDKSample/STMobSDKSample/ViewController.h b/STMobSDKSample/STMobSDKSample/ViewController.h new file mode 100644 index 0000000..a0f4381 --- /dev/null +++ b/STMobSDKSample/STMobSDKSample/ViewController.h @@ -0,0 +1,15 @@ +// +// ViewController.h +// STMobSDKSample +// +// Created by East on 16/4/22. +// Copyright © 2016年 sunteng. All rights reserved. +// + +#import + +@interface ViewController : UIViewController + + +@end + diff --git a/STMobSDKSample/STMobSDKSample/ViewController.m b/STMobSDKSample/STMobSDKSample/ViewController.m new file mode 100644 index 0000000..2f916b2 --- /dev/null +++ b/STMobSDKSample/STMobSDKSample/ViewController.m @@ -0,0 +1,115 @@ +// +// ViewController.m +// STMobSDKSample +// +// Created by East on 16/4/22. +// Copyright © 2016年 sunteng. All rights reserved. +// + +#import "ViewController.h" +#import "SuntengMobileAdsSDK.h" + +@interface ViewController () + +@property (nonatomic, weak) IBOutlet UITextView *logView; +@property (nonatomic, weak) STMInterstitialAdController *interstitialAdController; +@property (nonatomic, assign) BOOL isLoading; + +@end + +@implementation ViewController + +#pragma mark - life cycle + +- (void)viewDidLoad { + [super viewDidLoad]; + // Do any additional setup after loading the view, typically from a nib. +} + +- (void)didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +#pragma mark - IBAction + +- (IBAction)loadAd :(UIButton*)sender{ + if (self.isLoading) { + return; + } + + self.isLoading = YES; + + if (!self.interstitialAdController) { + self.interstitialAdController = [STMInterstitialAdController interstitialAdControllerWithPublishedId:@"2" + appId:@"23" + placementId:@"24"]; + self.interstitialAdController.delegate = self; + } + + [self.interstitialAdController loadAd]; + + NSMutableString *logString = [NSMutableString stringWithString:@"Start to load ad ...\n--------\n"]; + [logString appendString:self.logView.text]; + self.logView.text = logString; +} + +- (IBAction)showInterstitialAd:(UIButton *)sender{ + if (self.interstitialAdController.isLoaded) { + [self.interstitialAdController presentFromViewController:self]; + } else { + NSLog(@"The interstitial ad is not loaded yet."); + + NSMutableString *logString = [NSMutableString stringWithString:@"Ad is no loaded.\n"]; + [logString appendString:self.logView.text]; + self.logView.text = logString; + } +} + +#pragma mark - STMInterstitialAdControllerDelegate + +- (void)interstitialDidLoad:(STMInterstitialAdController *)interstitial { + NSLog(@"Now can present the interstitial ad."); + + NSMutableString *logString = [NSMutableString stringWithString:@"Success to load ad.\n"]; + [logString appendString:self.logView.text]; + self.logView.text = logString; +} + +- (void)interstitialDidLoadFail:(STMInterstitialAdController *)interstitial { + NSLog(@"The interstitial ad load fail."); + + NSMutableString *logString = [NSMutableString stringWithString:@"--------\nFail to load ad.\n"]; + [logString appendString:self.logView.text]; + self.logView.text = logString; + + self.isLoading = NO; +} + +- (void)interstitialDidPresent:(STMInterstitialAdController *)interstitial { + NSLog(@"The interstitial ad presented."); + + NSMutableString *logString = [NSMutableString stringWithString:@"Presented ad.\n"]; + [logString appendString:self.logView.text]; + self.logView.text = logString; +} + +- (void)interstitialDidTap:(STMInterstitialAdController *)interstitial { + NSLog(@"The interstitial ad taped."); + + NSMutableString *logString = [NSMutableString stringWithString:@"Ad taped.\n"]; + [logString appendString:self.logView.text]; + self.logView.text = logString; +} + +- (void)interstitialDidDismiss:(STMInterstitialAdController *)interstitial { + NSLog(@"The interstitial ad dismissed."); + + NSMutableString *logString = [NSMutableString stringWithString:@"--------\nDismiss ad.\n"]; + [logString appendString:self.logView.text]; + self.logView.text = logString; + + self.isLoading = NO; +} + +@end diff --git a/STMobSDKSample/STMobSDKSample/main.m b/STMobSDKSample/STMobSDKSample/main.m new file mode 100644 index 0000000..ffc85cb --- /dev/null +++ b/STMobSDKSample/STMobSDKSample/main.m @@ -0,0 +1,16 @@ +// +// main.m +// STMobSDKSample +// +// Created by East on 16/4/22. +// Copyright © 2016年 sunteng. All rights reserved. +// + +#import +#import "AppDelegate.h" + +int main(int argc, char * argv[]) { + @autoreleasepool { + return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); + } +}