123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359 |
- //
- // ViewController.m
- // NatureDemo
- //
- // Created by SAGESSE on 2019/1/20.
- // Copyright © 2019 SAGESSE. All rights reserved.
- //
- #import "ViewController.h"
- #import "XSTracker.h"
- @interface KL: UIView
- @end
- @implementation KL
- + (Class)layerClass {
- return CAGradientLayer.self;
- }
- @end
- @interface GameSDK : NSObject
- + (XenonSDK*)sharedSDK;
- @end
- @implementation GameSDK
- + (XenonSDK*)sharedSDK {
- return XenonSDK.sharedSDK;
- }
- @end
- @interface ViewController ()
- @end
- @implementation ViewController
- - (void)test {
-
-
- // 主动初始化SDK
- [GameSDK.sharedSDK initWithParameter:@"appid|channelId|appinfo" complete:^(NSError * error) {
- // 如果error不为空,初始化失败
- // 请使用error.localizedDescription和error.code确定错误原因.
- }];
-
-
- // 主动登录帐号
- [GameSDK.sharedSDK loginWithComplete:^(NSDictionary* user, NSError * error) {
- // 如果error不为空,登录失败
- // 请使用error.localizedDescription和error.code确定错误原因.
- }];
-
-
- // 主动登出帐号
- [GameSDK.sharedSDK logoutWithComplete:^{
- // 登出成功
- }];
-
- // 注册登出游戏的方法(注意引用循环)
- [GameSDK.sharedSDK logoutWhenNotification:^{
- // SDK要求游戏切换到登录页,
- }];
-
-
- // 主动切换帐号
- [GameSDK.sharedSDK logoutWithComplete:^{
- [GameSDK.sharedSDK loginWithComplete:^(NSDictionary* user, NSError * error) {
- // 如果error不为空,登录失败.
- // 请使用error.localizedDescription和error.code确定错误原因.
- }];
- }];
-
-
- // 生成订单信息
- id order = @{
- @"orderId": NSUUID.UUID.UUIDString,
- @"productCode": @"648",
- @"amount": @"648",
- @"productName": @"648元宝",
- @"serverId": @"1",
- @"roleName": @"用户",
- @"roleLevel": @"1",
- @"virtualCurrencyAmount": @"6480",
- @"extraInfo": @"11"
- };
-
- // 主动下单
- [GameSDK.sharedSDK buy:order complete:^(id info, NSError * error) {
- //如果error不为空购买失败, 请使用error.localizedDescription和error.code确定错误原因.
-
-
- }];
-
-
- // 主动上报角色信息
- [GameSDK.sharedSDK reportWithRoleName:@"Suave"
- level:60
- serverId:@"结伴同游"];
- }
- - (void)loadView {
- [super loadView];
- KL* view = [[KL alloc] initWithFrame:self.view.frame];
- CAGradientLayer* gr = (id)view.layer;
- gr.colors = @[(__bridge id)UIColor.orangeColor.CGColor,
- (__bridge id)UIColor.purpleColor.CGColor];
- view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
- [self.view insertSubview:view atIndex:0];
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view, typically from a nib.
- self.view.backgroundColor = [UIColor whiteColor];
- //[self active:nil];
-
- //20309|1105|534383&xsdmxios_IOS_0001
-
- [XenonSDK.sharedSDK initWithParameter:@"20387|1105|673842&gfqkhIOS_IOS_0001" complete:^(NSError * error) {
- //登录
-
- // if (error == nil) {
- // [XenonSDK.sharedSDK GMAdSDKinit];
- // }
-
- // [XenonSDK.sharedSDK loginWithComplete:^(id user, NSError * error) {
- //
- // NSLog(@"SDK初始化成功");
- // }];
-
- [[XenonSDK sharedSDK] xautoWithComplete:^(id user, NSError *error) {
- }];
-
-
-
- }];
-
- }
- /**
- - (void)extracted {
- [XenonSDK.sharedSDK loginWithComplete:^(id user, NSError * error) {
- NSLog(@"SDK初始化成功");
- }];
- }
- - (IBAction)active:(id)sender {
-
- //测试使用
- #define NT 0
- #if NT == 0
- // 正式环境
- [XenonSDK.sharedSDK initWithParameter:@"20194|1104|475316&iOScsyx_test_0001" complete:^(NSError * error) {
- [self extracted];
- }];
- #endif
- #if NT == 1
- // 测试环境x
- [XenonSDK.sharedSDK setBaseURL:@"http://ta.funcheergame.com"];
- [XenonSDK.sharedSDK initWithParameter:@"20194|1104|625350&iOScsyx_test_0001" complete:^(NSError * error) {
- [XenonSDK.sharedSDK loginWithComplete:^(id user, NSError * error) {
- NSLog(@"%s %@", __func__, error);
- }];
- }];
- #endif
- #if NT == 2
- // 开发环境
- [XenonSDK.sharedSDK setBaseURL:@"http://192.168.1.116:9099"];
- [XenonSDK.sharedSDK initWithParameter:@"20194|1104|625350&iOScsyx_test_0001" complete:^(NSError * error) {
- [XenonSDK.sharedSDK loginWithComplete:^(id user, NSError * error) {
- NSLog(@"%s %@", __func__, error);
- }];
- }];
- #endif
- #if NT == 3
- // 海外环境
- [XenonSDK.sharedSDK setBaseURL:@"https://abundant.sincerevirtue.com"];
- [XenonSDK.sharedSDK initWithParameter:@"20194|1104|475316&iOScsyx_test_0001" complete:^(NSError * error) {
- [XenonSDK.sharedSDK loginWithComplete:^(id user, NSError * error) {
- NSLog(@"%s %@", __func__, error);
- }];
- }];
- #endif
- }
- */
-
- - (IBAction)login:(id)sender {
-
- [XenonSDK.sharedSDK loginWithComplete:^(id user, NSError * error) {
- NSLog(@"登录成功返回结果%@:=========",user);
- }];
- }
- - (IBAction)logout:(id)sender {
-
- [XenonSDK.sharedSDK logoutWithComplete:^{
- NSLog(@"退出成功");
- }];
-
- }
- - (IBAction)pay:(id)sender {
-
- id ps = @{
- @"amount": @"6",
- @"productName": @"6元宝",
- @"productCode": @"6",
- @"roleName": @"roleName",
- @"orderId": NSUUID.UUID.UUIDString,
- @"serverId": @"serverId",
- @"extraInfo": @"extraInfo"
- };
- [XenonSDK.sharedSDK buy:ps complete:^(id order, NSError * error) {
- NSLog(@"支付成功返回订单结果%@:=========",order);
- NSLog(@"支付参数%@:=========",ps);
- }];
- }
- - (IBAction)userCenter:(id)sender {
- [XenonSDK.sharedSDK center];
- }
- //上报游戏角色.
- - (IBAction)report:(id)sender {
-
- [XenonSDK.sharedSDK reportWithRoleName:@"Suave"
- level:60
- serverId:@"结伴同游"];
- }
- //清除缓存.
- - (IBAction)clean:(id)sender {
-
- //清除cookies
- NSHTTPCookie *cookie;
- NSHTTPCookieStorage *storage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
- for (cookie in [storage cookies]){
- [storage deleteCookie:cookie];
- }
-
- //清除UIWebView的缓存
- [[NSURLCache sharedURLCache] removeAllCachedResponses];
- NSURLCache * cache = [NSURLCache sharedURLCache];
- [cache removeAllCachedResponses];
- [cache setDiskCapacity:0];
- [cache setMemoryCapacity:0];
-
- }
- //打开横幅广告
- - (IBAction)adBanner:(id)sender {
-
- [[XenonSDK sharedSDK] adBanner:@"banner_001"];
- }
- //打开插页广告
- - (IBAction)adInner:(id)sender {
-
- [[XenonSDK sharedSDK] openInterstitialAd:@"interstital_Test001" callback:^(BOOL result) {
- if (result) {
- NSLog(@"YES");
- }else{
- NSLog(@"NO");
- }
- }];
- }
- //打开视频激励广告
- - (IBAction)adVideo:(id)sender {
-
- [[XenonSDK sharedSDK] openVideoAd:@"video_test01" callback:^(BOOL result) {
-
- if (result) {
- NSLog(@"用户看完视频了,可以发放奖励了");
- }else{
- NSLog(@"视频还没加载好");
- }
- //观看过程中退出
- }];
- }
- //关闭横幅广告
- - (IBAction)closeBanner:(id)sender {
-
- NSLog(@"关闭横幅广告");
- //横幅广告 name:banner 参数必须一致.
- [[XenonSDK sharedSDK] closeAd:@"banner"];
- }
- //打开原生广告
- - (IBAction)nativeAd:(id)sender {
-
- //PS:这里参数格式可以修改.按照这种格式修改(x,y,w,h)
- [[XenonSDK sharedSDK] openNativeAdWithCenterX:40 Y:40 width:240 height:150];
-
- }
- //关闭原生广告
- - (IBAction)closeNativeAd:(id)sender {
- //原生广告 name:native 参数必须一致.
- [[XenonSDK sharedSDK] closeAd:@"native"];
-
- }
- //广告是否可用
- - (IBAction)bannerIsReady:(id)sender {
-
- BOOL result = [[XenonSDK sharedSDK] isAvailableAd:@"video_test01"];
- if (result) {
- NSLog(@"广告已准备好.");
- }else{
- NSLog(@"广告未准备好.");
- }
- }
- ///工具测试API
- - (IBAction)TestApi:(id)sender {
-
- //1.手机震动接口调用
- // [[XenonSDK sharedSDK] iphoneVibrate];
-
-
- //2.跳转到appstore商店评论
- // [[XenonSDK sharedSDK] skipToAppsotreWithID:@"1435569339"];
-
-
- //3.初始化自动登录
- // [[XenonSDK sharedSDK] xautoWithComplete:^(id user, NSError *error) {
- //
- //
- // }];
-
- //4.初始化手动登录
- // [XenonSDK.sharedSDK logoutWithComplete:^{
- // NSLog(@"退出成功");
- // [[XenonSDK sharedSDK] manualLogin];
- // }];
-
-
- //5.统计事件
- //[XenonSDK.sharedSDK tjEvent:0x0110];
- [XenonSDK.sharedSDK tjEvent:0x0112 value:@"登录测试"];
- }
- @end
|