MainViewController.m 3.71 KB
//
//  MainViewController.m
//  Demo_qiyu
//
//  Created by 许 on 17/6/7.
//  Copyright © 2017年 winFan. All rights reserved.
//

#import "MainViewController.h"
#import "PoolSdk.h"

@interface MainViewController ()

@end

@implementation MainViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveSDKMessage:) name:poolSDK_Notification object:nil];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

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


- (void)receiveSDKMessage:(NSNotification *)notification
{
    PoolSDKResult *result = [notification object];
    if (result) {
        NSLog(@"notiType:%d",result.notiType);
        switch (result.notiType) {
                
            case PoolSDKNotificationInitSDK:
            {
                NSLog(@"sdk初始化成功");
            }
                
                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 PoolSDKNotificationLogout:
            {
                NSLog(@"sdk注销成功,游戏处理");
            }
                break;
            default:
                break;
        }
    }
}

- (IBAction)actionInit:(id)sender {
    [[PoolSdk shareSDK]initSDK:self];
}
- (IBAction)actionLogin:(id)sender {
    [[PoolSdk shareSDK] loginSDK];
}

- (IBAction)actionPay:(id)sender {
    PoolCreateOrderInfo *payInfo = [[PoolCreateOrderInfo alloc]init];
    [payInfo setServerId:@"111"];
    [payInfo setPlayerName:@"roleName"];
    [payInfo setPlayerLevel:@"10"];
    [payInfo setPostAmount:@"6"];
    [payInfo setProductId:@"com.fytx.6"];
    [payInfo setPlayerId:@"1231241234"];
    [payInfo setTimestamp:@"1232134"];
    [payInfo setExchange:@"10"];
    [payInfo setCustom:@"custom"];
    NSLog(@"start pay");
    [[PoolSdk shareSDK] payWithPaymentInfo:payInfo];
}


/**
 serverid
 servername
 roleid
 rolename
 rolelevel
*/
- (IBAction)actionSubmitRoleData:(id)sender {
    NSLog(@"数据接口");
    PoolReportInfo *reportInfo = [[PoolReportInfo alloc]init];
    [reportInfo setReportType:REPORT_ENTER];
    //[reportInfo setReportType:REPORT_CREATEROLE];
    //[reportInfo setReportType:REPORT_ROLEUPGRADE]
    [reportInfo setServerId:@"9133"];
    [reportInfo setServerName:@"serverName"];
    [reportInfo setPlayerId:@"123456"];
    [reportInfo setPlayerName:@"playName"];
    [reportInfo setPlayerLevel:@"100"];
    [[PoolSdk shareSDK] reportSDK:reportInfo];
}

- (IBAction)actionLogout:(id)sender {
    NSLog(@"注销");
    [[PoolSdk shareSDK] logoutSDK];
}


@end