Skip to content

Commit

Permalink
v2.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
许忠洲 committed Nov 9, 2016
1 parent 4a9fcd4 commit 855e2a8
Show file tree
Hide file tree
Showing 51 changed files with 778 additions and 691 deletions.
44 changes: 25 additions & 19 deletions Docs/Getting_Started.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 舜飞移动广告 SDK iOS 版 v1.x.x 开发文档
# 舜飞移动广告 SDK iOS 版 v2.x.x 开发文档

## 1、开发环境

Expand All @@ -9,13 +9,12 @@

## 2、SDK 集成

2.1、将最新的 SDK 文件夹,包含头文件 `SuntengMobileAdsSDK.h``STMBannerView.h``STMInterstitialAdController.h``STMSplashAd.h` 和静态库 `libSuntengMobileAdsSDK.a` 加入项目中。
2.1、将最新的 SDK 文件夹,包含头文件 `SuntengMobileAdsSDK.h``STMConstants.h``STMBannerView.h``STMInterstitialAdController.h``STMSplashAd.h` 和静态库 `libSuntengMobileAdsSDK.a` 加入项目中。

2.2、添加需要的 Framework:

```objc
AdSupport.framework
CoreFoundation.framework
CoreGraphics.framework
CoreLocation.framework
CoreTelephony.framework
Expand All @@ -31,8 +30,11 @@ UIKit.framework

在 info.plist 里加入对应的定位请求字段,值可以为空或者填写获取定位请求提示框要显示的内容。

```objc
NSLocationWhenInUseUsageDescription // 允许在前台获取GPS的描述
```XML
<key>NSLocationWhenInUseUsageDescription</key>
<string>iOS 8 定位权限请求提示语!</string>
<key>NSLocationUsageDescription</key>
<string>iOS 10 定位权限请求提示语!</string>
```

**说明:由于部分广告会定向投递到某些城市,SDK 需要获取地理位置以支持广告的定向投放。**
Expand Down Expand Up @@ -72,15 +74,14 @@ NSLocationWhenInUseUsageDescription // 允许在前台获取GPS的描述
#### 3.1.1、初始化横幅 SDK

```objc
self.bannerView = [[STMBannerView alloc] initWithPublishedId:@"1"
appId:@"2"
placementId:@"4"
frame:CGRectMake(0, 0, 320, 50)];
self.bannerView = [[STMBannerView alloc] initWithPublisherID:@"2"
appID:@"36"
placementID:@"35"
appKey:@"Ac7Kd3lJ^KQX9Hjkn_Z(UO9jqViFh*q1"
frame:CGRectMake(0, 64, 320, 50)];
[self.bannerView loadAd];
```
**建议使用 Banner 尺寸 320x50、640x100、1080x120,单位为像素。**
#### 3.1.2、展示横幅广告
```objc
Expand Down Expand Up @@ -130,9 +131,10 @@ if (self.bannerView.isLoaded) {
#### 3.2.1、初始化插屏 SDK

```objc
self.interstitialAdController = [STMInterstitialAdController interstitialAdControllerWithPublishedId:@"1"
appId:@"2"
placementId:@"3"];
self.interstitialAdController = [STMInterstitialAdController interstitialAdControllerWithPublisherID:@"2"
appID:@"36"
placementID:@"36"
appKey:@"Ac7Kd3lJ^KQX9Hjkn_Z(UO9jqViFh*q1"];
```
#### 3.2.2、展示插屏广告
Expand Down Expand Up @@ -190,9 +192,11 @@ if (self.interstitialAdController.isLoaded) {
[self.window makeKeyAndVisible];

// 初始化开屏 SDK
self.splashAd = [STMSplashAd splashAdWithPublishedId:@"1"
appId:@"2"
placementId:@"5"];
self.splashAd = [STMSplashAd splashAdWithPublisherID:@"2"
appID:@"36"
placementID:@"34"
appKey:@"Ac7Kd3lJ^KQX9Hjkn_Z(UO9jqViFh*q1"];

self.splashAd.delegate = self;

// 展示开屏广告
Expand All @@ -212,7 +216,7 @@ if (self.interstitialAdController.isLoaded) {
- (void)splashDidPresent:(STMSplashAd *)splash;

// 当开屏广告展示失败后,回调该方法
- (void)splashlFailPresent:(STMSplashAd *)splash;
- (void)splashFailPresent:(STMSplashAd *)splash;

// 当用户点击广告,回调该方法
- (void)splashDidTap:(STMSplashAd *)splash;
Expand All @@ -223,8 +227,10 @@ if (self.interstitialAdController.isLoaded) {

#### 3.3.2、设置实时开屏广告请求超时时间

当本地没有缓存的开屏广告或者本地已缓存广告超时, SDK 会发起实时开屏广告请求,实时开屏广告超时时间默认设定为 2 秒,以提高用户体验。您可以通过以下方法自定义超时时间,以提高实时开屏广告展示的成功几率。**强烈建议您保持该设置以提高用户体验!**
开屏广告混合了缓存的开屏广告和实时获取功能。当本地没有缓存的开屏广告或者本地已缓存广告超时时, SDK 会发起实时开屏广告请求,实时开屏广告超时时间内默认设定为 2 秒,以提高用户体验。您可以通过以下方法自定义超时时间,以提高实时开屏广告展示的成功几率。

```objc
- (void)setRealtimeSplashTimeoutInterval:(CGFloat)interval;
```


725 changes: 507 additions & 218 deletions Docs/舜飞移动广告SDK开发文档.html

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@

## Change Log

11/09/2016 - v2.0.3

* Update API.
* bugs fixes.

06/20/2016 - v1.1.0

* add splash and banner ad.
Expand Down
38 changes: 28 additions & 10 deletions STMobSDK/STMBannerView.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

#import <UIKit/UIKit.h>
#import "STMConstants.h"

NS_ASSUME_NONNULL_BEGIN

Expand All @@ -21,25 +22,42 @@ NS_ASSUME_NONNULL_BEGIN
/**
* Create and return a `STMBannerView` instance.
*
* @param publishedId The published id.
* @param appId The app id.
* @param placementId The placement id.
* @param publisherID The publisher ID.
* @param appID The app ID.
* @param placementID The placement ID.
* @param appKey The app key.
* @param frame The banner view frame.
*
* @return A `STMInterstitialAdController` instance.
*/
- (nullable instancetype)initWithPublishedId:(NSString *)publishedId
appId:(NSString *)appId
placementId:(NSString *)placementId
- (nullable instancetype)initWithPublisherID:(NSString *)publisherID
appID:(NSString *)appID
placementID:(NSString *)placementID
appKey:(NSString *)appKey
frame:(CGRect)frame;

- (instancetype)init __attribute__((unavailable("can not use `- init` method, please use `- initWithPublishedId:appId:placementId:frame:` method")));
+ (instancetype)new __attribute__((unavailable("can not use `+ new` method, please use `- initWithPublishedId:appId:placementId:frame:` method")));
- (instancetype)init __attribute__((unavailable("can not use `- init` method, please use `- initWithPublisherId:appId:placementId:appKey:frame:` method")));
+ (instancetype)new __attribute__((unavailable("can not use `+ new` method, please use `- initWithPublisherId:appId:placementId:appKey:frame:` method")));

/**
* The placement Id.
* The poublisher ID.
*/
@property (nonatomic, copy, readonly) NSString *adUnitID;
@property (nonatomic, copy, readonly) NSString *publisherID;

/**
* The app ID.
*/
@property (nonatomic, copy, readonly) NSString *appID;

/**
* The placement ID.
*/
@property (nonatomic, copy, readonly) NSString *placementID;

/**
* The app key.
*/
@property (nonatomic, copy, readonly) NSString *appKey;

/**
* The `STMBannerView` delegate.
Expand Down
27 changes: 27 additions & 0 deletions STMobSDK/STMConstants.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//
// STMConstants.h
// SuntengMobileAdsSDK
//
// Created by Joe.
// Copyright © 2016年 Sunteng Information Technology Co., Ltd. All rights reserved.
//

#import <Foundation/Foundation.h>

extern NSString * const STMErrorDomain;

typedef NS_ENUM(NSInteger, STMErrorCode) {
STMErrorCodeNone = 0, // bidding success
STMErrorCodeNetworkError, // network error
STMErrorCodeResponseError, // response is not a HTTP URL response
STMErrorCodeSystemError, // server system error
STMErrorCodeNoAd, // no ad
STMErrorCodeNoData, // no response data
STMErrorCodeDeserializationError, // deserialize JSON error
STMErrorCodeLoadHTMLFail, // load HTML fail
STMErrorCodeErrorRequest, // error request - HTTP code 204
STMErrorCodeRefund, // no ad - refund
STMErrorCodeBlank, // no ad - keep blank
STMErrorCodeTimeout, // timeout
STMErrorCodeOther = -1 // other error
};
41 changes: 30 additions & 11 deletions STMobSDK/STMInterstitialAdController.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

#import <UIKit/UIKit.h>
#import "STMConstants.h"

NS_ASSUME_NONNULL_BEGIN

Expand All @@ -21,23 +22,41 @@ NS_ASSUME_NONNULL_BEGIN
/**
* Create and return a `STMInterstitialAdController` instance.
*
* @param publishedId The published id.
* @param appId The app id.
* @param placementId The placement id.
* @param publisherID The publisher ID.
* @param appID The app ID.
* @param placementID The placement ID.
* @param appKey The app key.
*
* @return A `STMInterstitialAdController` instance.
*/
+ (nullable instancetype)interstitialAdControllerWithPublishedId:(NSString *)publishedId
appId:(NSString *)appId
placementId:(NSString *)placementId;
+ (nullable instancetype)interstitialAdControllerWithPublisherID:(NSString *)publisherID
appID:(NSString *)appID
placementID:(NSString *)placementID
appKey:(NSString *)appKey;

- (instancetype)init __attribute__((unavailable("can not use `- init` method, please use `+ interstitialAdControllerWithPublishedId:appId:placementId:` method")));
+ (instancetype)new __attribute__((unavailable("can not use `+ new` method, please use `+ interstitialAdControllerWithPublishedId:appId:placementId:` method")));
- (instancetype)init __attribute__((unavailable("can not use `- init` method, please use `+ interstitialAdControllerWithPublisherID:appID:placementID:appKey:` method")));
+ (instancetype)new __attribute__((unavailable("can not use `+ new` method, please use `+ interstitialAdControllerWithPublisherID:appID:placementID:appKey:` method")));

/**
* The placement Id.
* The publisher ID.
*/
@property (nonatomic, copy, readonly) NSString *adUnitID;
@property (nonatomic, copy, readonly) NSString *publisherID;

/**
* The app ID.
*/
@property (nonatomic, copy, readonly) NSString *appID;

/**
* The placement ID.
*/
@property (nonatomic, copy, readonly) NSString *placementID;

/**
* The appKey.
*/
@property (nonatomic, copy, readonly) NSString *appKey;


/**
* The `STMInterstitialAdController` delegate.
Expand Down Expand Up @@ -83,7 +102,7 @@ NS_ASSUME_NONNULL_BEGIN
*
* @param interstitial The `STMInterstitialAdController` instance.
*/
- (void)interstitialDidLoadFail:(STMInterstitialAdController *)interstitial;
- (void)interstitial:(STMInterstitialAdController *)interstitial didLoadFailWithError:(NSError *)error;

/**
* The interstitial ad presented.
Expand Down
42 changes: 30 additions & 12 deletions STMobSDK/STMSplashAd.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
// Copyright © 2016年 Sunteng Information Technology Co., Ltd. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import "STMConstants.h"

NS_ASSUME_NONNULL_BEGIN

Expand All @@ -22,23 +23,40 @@ NS_ASSUME_NONNULL_BEGIN
/**
* Create and return a `STMSplashAd` instance.
*
* @param publishedId The published id.
* @param appId The app id.
* @param placementId The placement id.
* @param publisherID The publisher ID.
* @param appID The app ID.
* @param placementID The placement ID.
* @param appKey The app key.
*
* @return A `STMSplashAd` instance.
*/
+ (nullable instancetype)splashAdWithPublishedId:(NSString *)publishedId
appId:(NSString *)appId
placementId:(NSString *)placementId;
+ (nullable instancetype)splashAdWithPublisherID:(NSString *)publisherID
appID:(NSString *)appID
placementID:(NSString *)placementID
appKey:(NSString *)appKey;

- (instancetype)init __attribute__((unavailable("can not use `- init` method, please use `+ initWithPublisherID:appID:placementID:appKey:` method")));
+ (instancetype)new __attribute__((unavailable("can not use `+ new` method, please use `+ initWithPublisherID:appID:placementID:appKey:` method")));

/**
* The publisher ID
*/
@property (nonatomic, copy, readonly) NSString *publisherID;

- (instancetype)init __attribute__((unavailable("can not use `- init` method, please use `+ initWithPublishedId:appId:placementId:` method")));
+ (instancetype)new __attribute__((unavailable("can not use `+ new` method, please use `+ initWithPublishedId:appId:placementId:` method")));
/**
* The app ID
*/
@property (nonatomic, copy, readonly) NSString *appID;

/**
* The placement ID
*/
@property (nonatomic, copy, readonly) NSString *placementID;

/**
* The placement Id
* The appKey
*/
@property (nonatomic, copy, readonly) NSString *adUnitID;
@property (nonatomic, copy, readonly) NSString *appKey;

/**
* The `STMSplashAd` delegate.
Expand Down Expand Up @@ -87,7 +105,7 @@ NS_ASSUME_NONNULL_BEGIN
*
* @param splash The `STMSplashAd` instance.
*/
- (void)splashlFailPresent:(STMSplashAd *)splash;
- (void)splash:(STMSplashAd *)splash failPresentWithError:(NSError *)error;

/**
* The splash ad tapped.
Expand Down
10 changes: 5 additions & 5 deletions STMobSDK/SuntengMobileAdsSDK.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@

NS_ASSUME_NONNULL_BEGIN

/**
* Sunteng mobile ad SDK version.
*/
extern NSString * const STMAdsSDKVersion;

@interface SuntengMobileAdsSDK : NSObject

/**
Expand All @@ -27,6 +22,11 @@ extern NSString * const STMAdsSDKVersion;
*/
+ (instancetype)sharedInstance;

/**
* Sunteng mobile ad SDK version.
*/
@property (nonatomic, strong, readonly) NSString *version;

- (instancetype)init __attribute__((unavailable("can not use `- init` method, please use `+ sharedInstance` method")));
+ (instancetype)new __attribute__((unavailable("can not use `+ new` method, please use `+ sharedInstance` method")));

Expand Down
Binary file modified STMobSDK/libSuntengMobileAdsSDK.a
Binary file not shown.
Loading

0 comments on commit 855e2a8

Please sign in to comment.