ViewController.m 4.58 KB

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    UIButton *button1 = [UIButton buttonWithType:UIButtonTypeCustom];
    [button1 setTitle:@"登陆" forState:UIControlStateNormal];
    button1.frame = CGRectMake(50.0f, 100.0f, 50.0f, 40.0f);
    button1.tag = 1;
    [button1 addTarget:self action:@selector(toggleButton:) forControlEvents: UIControlEventTouchUpInside];
    [self.view addSubview:button1];
    
    UIButton *button2 = [UIButton buttonWithType:UIButtonTypeCustom];
    [button2 setTitle:@"数据" forState:UIControlStateNormal];
    button2.frame = CGRectMake(150.0f, 100.0f, 50.0f, 40.0f);
    button2.tag = 2;
    [button2 addTarget:self action:@selector(toggleButton:) forControlEvents: UIControlEventTouchUpInside];
    [self.view addSubview:button2];
    
    UIButton *button4 = [UIButton buttonWithType:UIButtonTypeCustom];
    [button4 setTitle:@"充值" forState:UIControlStateNormal];
    button4.frame = CGRectMake(150.0f, 50.0f, 50.0f, 40.0f);
    button4.tag = 4;
    [button4 addTarget:self action:@selector(toggleButton:) forControlEvents: UIControlEventTouchUpInside];
    [self.view addSubview:button4];

  
    UIButton *button6 = [UIButton buttonWithType:UIButtonTypeCustom];
    [button6 setTitle:@"获取配置参数" forState:UIControlStateNormal];
    button6.frame = CGRectMake(10.0f, 50.0f, 150.0f, 40.0f);
    button6.tag = 6;
    [button6 addTarget:self action:@selector(toggleButton:) forControlEvents: UIControlEventTouchUpInside];
    [self.view addSubview:button6];
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveSDKMessage:) name:poolSDK_Notification object:nil];
    
    [[PoolSdk shareSDK]initSDK:self];
}

-(void)viewDidAppear:(BOOL)animated{
    [super viewDidAppear:animated];
    //[[PoolSdk shareSDK] viewDidAppear];
}


- (void) toggleButton: (UIButton *) button
{
    int tag = (int)button.tag;
    if (tag == 1) {
        [[PoolSdk shareSDK] loginSDK];
    }
    else if (tag == 2)
    {
         NSLog(@"数据接口");
        PoolReportInfo *reportInfo = [[PoolReportInfo alloc]init];
        [reportInfo setReportType:REPORT_ENTER];
        //[reportInfo setReportType:REPORT_CREATEROLE];
        //[reportInfo setReportType:REPORT_ROLEUPGRADE]
        [reportInfo setServerId:@"9133"];
        [reportInfo setPlayerName:@"roleName"];
        [reportInfo setPlayerId:@"pserverName"];
        [[PoolSdk shareSDK] reportSDK:reportInfo];
    }
    else if (tag == 4)
    {
        PoolCreateOrderInfo *payInfo = [[PoolCreateOrderInfo alloc]init];
        [payInfo setServerId:@"111"];
        [payInfo setPostAmount:@"6"];
        [payInfo setPlayerId:@"1231241234"];
        [payInfo setTimestamp:@"1232134"];
        [payInfo setExchange:@"10"];
        [payInfo setCustom:@"custom"];
        NSLog(@"start pay");
        [[PoolSdk shareSDK] gzyazfWithGzyazfmentInfo:payInfo];
    }
    else if(tag == 6){
        PoolSdk *poolSdk = [PoolSdk shareSDK];
        NSLog(@"channelId:%@parame1:%@parame2:%@custom:%@",[poolSdk getGameChannelId],[poolSdk getChannelParameter1],[poolSdk getChannelParameter2],[poolSdk getCustomValue]);
    }
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

- (void)receiveSDKMessage:(NSNotification *)notification
{
    NSLog(@"receiveSDKMessage");
    [[PoolConfig getInstance] getValueByKey:@"gamechannelid"];
    PoolSDKResult *result = [notification object];
    if (result == nil ) {
        return;
    }
    switch (result.notiType) {
        
        case PoolSDKNotificationInitSDK:
        {
            NSLog(@"收到PoolSDKNotificationInitSDK");
        }
            
        break;
        case PoolSDKNotificationLogin:
        {
            NSLog(@"result state:%d",result.statusCode);
            if (result.statusCode == POOLSDK_NO_ERROR) {
                PoolLoginInfo *loginInfo = (PoolLoginInfo*)result.extendData;
                NSLog(@"收到登陆信息public openid:%@", [loginInfo openId]);
                NSLog(@"收到登陆信息public token:%@", [loginInfo sign]);
                NSLog(@"收到登陆信息public timestamp:%@", [loginInfo timestamp]);
                NSLog(@"userType:%@",[loginInfo userType]);
            }else{
                NSLog(@"%@",[result description]);
            }
        }
            break;
        case PoolSDKNotificationGzyazf:
        {
            NSLog(@"收到登陆信息PoolSDKNotificationPay");
        }
            break;
        default:
            break;
    }
}

@end