Đây là bài viết để anh em add quảng cáo StartApp vô ứng dụng IOS nhằm tăng gia sản xuát thêm cho các anh em. Theo cảm nhận của mình StartApp vừa đơn giản quảng cáo đẹp mà năng suất lại cao.
1, Đầu tiên anh em vô https://portal.startapp.com/signup để đăng ký.
Sau khi đăng ký thì anh em đăng nhập vô.
2, Anh em vô My Applications Click vô mục Add New App
1, Đầu tiên anh em vô https://portal.startapp.com/signup để đăng ký.
Sau khi đăng ký thì anh em đăng nhập vô.
2, Anh em vô My Applications Click vô mục Add New App
điền thông tin link app (nếu có), tiếp đến tên app. Chọn Platform là iOS, điền thông tin app, maturity cuối cùng là nhấn vô button add app.
Sau đó anh em sẽ có app id đồng thời anh em download SDK của startapp. (Anh em lựa chọn sdk cho app của mình là in app hay unity, cocos2d hay cocos2dx tuỳ theo app anh em.) Ở đây mình chọn in app.
Có 1 project ví dụ của startapp đã add cho anh em tham khảo.
https://github.com/StartApp-SDK/StartApp-InApp-iOS-Example-App/archive/master.zip
sau khi download sdk về thì giải nén ra ta đưa vô project
Startapp có mấy kiểu quảng cáo: Splash Ads là kiểu quảng cáo khi mở ứng dụng, cái này có ecpm cao nhất.
Quảng cáo
Đối với các bạn code Objective C có document đây thì để add:
1. các bạn mở project cần add bằng xcode lên và chuột phải project chọn Add Files to "tên project của bạn" (hoặc kéo thư mục sdk vừa download về vô trực tiếp project của bạn.)
2. Chọn file StartApp.framework vs StartApp.bundle
3. Vô project->application target -> Build Phases-> "Link Binary with Libraries" chọn thêm các framwork:
CoreTelephony.framework
Quảng cáo
SystemConfiguration.framework
CoreGraphics.framework
StoreKit.framework
AdSupport.framework
QuartzCore.framework
libz.dylib
Tiếp đến các bạn cần thêm vô file AppDelegate.m
trong
- (BOOL)application😔UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
Code:
#import <StartApp/StartApp.h> - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // initialize the SDK with your appID and devID STAStartAppSDK* sdk = [STAStartAppSDK sharedInstance]; sdk.devID = @"your developer id"; sdk.appID = @"your app Id"; return YES; }
Để hiển thị quảng cáo Splash Ads lúc đầu thì các bạn add tiếp
[sdk showSplashAd];
vô trên được như sau:
Code:
#import <StartApp/StartApp.h> - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // initialize the SDK with your appID and devID STAStartAppSDK* sdk = [STAStartAppSDK sharedInstance]; sdk.appID = @"your app Id"; sdk.devID = @"your developer id"; [sdk showSplashAd]; // display the splash screen return YES; }
ViewController.h của các bẩn và thêm vô
#import <StartApp/StartApp.h>
STAStartAppAd* startAppAd;
được như sau:
Code:
#import <StartApp/StartApp.h> @interface YourViewController : UIViewController { STAStartAppAd* startAppAd; // ADD THIS LINE }
[super viewDidLoad];
startAppAd = [[STAStartAppAd alloc] init];
và trong viewDidAppear thêm:
[startAppAd loadAd];
còn trong dealloc(nếu có) thêm:
[startAppAd release];
ta được như sau:
Code:
- (void)viewDidLoad { [super viewDidLoad]; startAppAd = [[STAStartAppAd alloc] init]; } - (void) viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; [startAppAd loadAd]; // Add this line } - (void) dealloc { // Don't release startAppAd if you are using ARC in your project [startAppAd release]; // Add this line [super dealloc]; }
[startAppAd showAd];
Hiển thị quảng cáo banners (Loại này ít tác dụng)
Trong file ViewController.h của các bạn cần thêm như sau:
Code:
#import <UIKit/UIKit.h> #import <StartApp/StartApp.h> @interface YourViewController : UIViewController { STABannerView* bannerView; }
if (bannerView == nil) {
bannerView = [[STABannerView alloc] initWithSize:STA_AutoAdSize autoOrigin:STAAdOrigin_Top
withView:self.view withDelegate:nil];
[self.view addSubview:bannerView];
}
và
[bannerView release];
ta được như sau:
Code:
- (void) viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; if (bannerView == nil) { bannerView = [[STABannerView alloc] initWithSize:STA_AutoAdSize autoOrigin:STAAdOrigin_Top withView:self.view withDelegate:nil]; [self.view addSubview:bannerView]; } } - (void) dealloc { // Don't release bannerView if you are using ARC in your project [bannerView release]; // Add this line [super dealloc]; }
Code:
- (void) didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation { [bannerView didRotateFromInterfaceOrientation:fromInterfaceOrientation]; [super didRotateFromInterfaceOrientation:fromInterfaceOrientation]; } - (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator { [bannerView viewWillTransitionToSize:size withTransitionCoordinator:coordinator]; [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator]; }
1. các bạn mở project cần add bằng xcode lên và chuột phải project chọn Add Files to "tên project của bạn" (hoặc kéo thư mục sdk vừa download về vô trực tiếp project của bạn.)
2.Chọn file StartApp.framework vs StartApp.bundle
3. Vô project->application target -> Build Phases-> "Link Binary with Libraries" chọn thêm các framwork:
CoreTelephony.framework
SystemConfiguration.framework
CoreGraphics.framework
StoreKit.framework
AdSupport.framework
QuartzCore.framework
libz.dylib
trong mục "Copy Bundle Resources" các bạn add StartApp.bundle nếu chưa tồn tại.
tiếp đến add file Bridging-Header như sau để dùng được code Objective C:
chuột phải project chọn add new file
chọn iOS->Source->Header File->Next
tên file -Bridging-Header.h”
kiểm tra xem trong "Build Settings" đúng link dẫn file Bridging-Header.h
thêm #import <StartApp/StartApp.h> vô file Bridging Header.
Bắt tay vào công đoạn chính là add code: vô file AppDelegate.swift được như sau:
Code:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool { // initialize the SDK with your appID and devID var sdk: STAStartAppSDK = STAStartAppSDK.sharedInstance() sdk.appID = "Your App Id" sdk.devID = "Your Developer Id" return true }
Để hiển thị quảng cáo Splash Ads lúc đầu thì các bạn add tiếp vô AppDelegate.swift
được như sau:
Code:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool { // initialize the SDK with your appID and devID var sdk: STAStartAppSDK = STAStartAppSDK.sharedInstance() sdk.appID = "Your App Id" sdk.devID = "Your Developer Id" sdk.showSplashAd() return true }
ViewController.swift của các bẩn và thêm vô được như sau:
Code:
var startAppAd: STAStartAppAd? override func viewDidLoad() { super.viewDidLoad() startAppAd = STAStartAppAd() } override func viewDidAppear(animated: Bool) { super.viewDidAppear(animated) startAppAd!.loadAd() }
Hiển thị quảng cáo banners (Loại này ít tác dụng)
Trong file ViewController.swift của các bạn cần thêm như sau:
Code:
var startAppBanner: STABannerView?
Code:
override func viewDidAppear(animated: Bool) { super.viewDidAppear(animated) if !startAppBanner { startAppBanner = STABannerView(size: STA_AutoAdSize, autoOrigin: STAAdOrigin_Bottom, withView: self.view, withDelegate: nil); self.view.addSubview(startAppBanner) } } override func didRotateFromInterfaceOrientation(fromInterfaceOrientation: UIInterfaceOrientation) { // notify StartApp auto Banner orientation change startAppBanner!.didRotateFromInterfaceOrientation(fromInterfaceOrientation) super.didRotateFromInterfaceOrientation(fromInterfaceOrientation) } override func viewWillTransitionToSize(size: CGSize, withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator) { // notify StartApp auto Banner orientation change startAppBannerAuto!.viewWillTransitionToSize(size, withTransitionCoordinator: coordinator) startAppBannerFixed!.viewWillTransitionToSize(size, withTransitionCoordinator: coordinator) super.viewWillTransitionToSize(size, withTransitionCoordinator: coordinator) }
goodcode!
các bạn có thắc mắc gì cứ hỏi nhé.