当前位置:编程学习 > wap >>

APP集成tapjoy积分墙

这边简单的写了一个tapjoy的积分墙Manager类,如果有需要大家可以下载,你只需要在显示积分墙的地方简单的调用manager类显示函数。


[plain]
[[CPTapjoyManager sharedTJManager] showOfferWall]; 

[[CPTapjoyManager sharedTJManager] showOfferWall];
CPTapjoyManager.h头文件


[plain]
#import <Foundation/Foundation.h> 
#import "TapjoyConnect.h" 
 
#define APP_ID @"fc145b41-7d9b-4942-9d90-6d87162794a5" 
#define APP_SECRET_KEY @"z1cWed53f0ZzRwnOaE3L" 
 
@inte易做图ce CPTapjoyManager : NSObject<TJCAdDelegate,TJCVideoAdDelegate,TJCViewDelegate,UIAlertViewDelegate> 

    int tapPoints; 
    UIWindow* rootWindow; 

 
 
+(CPTapjoyManager*) sharedTJManager; 
 
 
 
-(void) showOfferWall; 
-(void)showBannerAd; 
-(void)dismissBannerAd; 
 
-(void)showFullScreenAd; 
 
@end 

#import <Foundation/Foundation.h>
#import "TapjoyConnect.h"

#define APP_ID @"fc145b41-7d9b-4942-9d90-6d87162794a5"
#define APP_SECRET_KEY @"z1cWed53f0ZzRwnOaE3L"

@inte易做图ce CPTapjoyManager : NSObject<TJCAdDelegate,TJCVideoAdDelegate,TJCViewDelegate,UIAlertViewDelegate>
{
    int tapPoints;
    UIWindow* rootWindow;
}


+(CPTapjoyManager*) sharedTJManager;

 

-(void) showOfferWall;
-(void)showBannerAd;
-(void)dismissBannerAd;

-(void)showFullScreenAd;

@end

CPTapjoyManager.m文件


[plain]
#import "CPTapjoyManager.h" 
#import "AppDelegate.h" 
#import "DataManager.h" 
 
 
static CPTapjoyManager * _tjManager; 
 
@implementation CPTapjoyManager 
 
+(CPTapjoyManager *)sharedTJManager 

    if(_tjManager==nil) 
    { 
        _tjManager = [[CPTapjoyManager alloc] init]; 
    } 
    return _tjManager; 

 
 
-(id)init 

    if(self == [super init]) 
    { 
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(tjcConnectSuccess:) name:TJC_CONNECT_SUCCESS object:nil]; 
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(tjcConnectFail:) name:TJC_CONNECT_FAILED object:nil]; 
         
        [TapjoyConnect requestTapjoyConnect:APP_ID 
                                  secretKey:APP_SECRET_KEY 
                                    options:@{ 
              TJC_OPTION_TRANSITION_EFFECT : @(TJCTransitionExpand), 
                 TJC_OPTION_ENABLE_LOGGING : @(YES), 
             TJC_OPTION_COLLECT_MAC_ADDRESS: @(TJCMacAddressOptionOffWithVersionCheck), 
         // If you are not using Tapjoy Managed currency, you would set your own user ID here. 
         //TJC_OPTON_USER_ID : @"A_UNIQUE_USER_ID" 
         }]; 
         
        //注册积分墙消息监视 
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(offerwallClosed:) name:TJC_VIEW_CLOSED_NOTIFICATION object:nil]; 
         
        //注册积分查询、消费监视 
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(getTJPoints:) name:TJC_TAP_POINTS_RESPONSE_NOTIFICATION object:nil]; 
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(getTJPointsError:) name:TJC_TAP_POINTS_RESPONSE_NOTIFICATION_ERROR object:nil]; 
         
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(consumeTJPoints:) name:TJC_SPEND_TAP_POINTS_RESPONSE_NOTIFICATION object:nil]; 
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(consumeTJPointsError:) name:TJC_SPEND_TAP_POINTS_RESPONSE_NOTIFICATION_ERROR object:nil]; 
         
        //注册全屏广告 
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(getTJFullScreenAd:) name:TJC_FULL_SCREEN_AD_RESPONSE_NOTIFICATION object:nil]; 
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(fullScreenAdClosed:) name:TJC_VIEW_CLOSED_NOTIFICATION object:nil]; 
 
 
         
    } 
    return self; 

 
//显示积分墙及获取积分 
-(void) showOfferWall 

    [TapjoyConnect showOffersWithViewController:[[AppDelegate sharedAppDelegate] rootViewController]]; 
    [TapjoyConnect getTapPoints]; 

//显示banner广告 
-(void)showBannerAd 

    [TapjoyConnect getDisplayAdWithDelegate:self]; 
    

-(void)dismissBannerAd 

    [[TapjoyConnect getDisplayAdView] removeFromSuperview]; 
    rootWindow = nil; 

//显示全屏广告 
-(void)showFullScreenAd 

    [TapjoyConnect getFullScreenAd]; 
 

#pragma mark Tapjoy Connect Observer Method 
 
//连接监视函数 
-(void)tjcConnectSuccess:(NSNotification*)notifyObj 

    NSLog(@"Tapjoy connect Succeeded"); 

 
 
- (void)tjcConnectFail:(NSNotification*)notifyObj 

    NSLog(@"Tapjoy connect Failed"); 

 
//积分墙监视函数 
-(void)offerwallClosed:(NSNotification*)notifyObj 

    NSLog(@"Offerwall closed"); 

补充:移动开发 , IOS ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,