12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112 |
- #import "XenonSDK.h"
- #import <Security/Security.h>
- #import <sys/utsname.h>
- #if SDK_HAS_IDFA
- #import <AdSupport/AdSupport.h>
- #endif
- #import "BubbleView.h"
- #import "RootViewController.h"
- #import "NoticeViewController.h"
- #import "UserBindPhoneViewController.h"
- #import "UserLoginFastViewController.h"
- #import "UserLoginPhoneViewController.h"
- #import "UserCenterViewController1.h"
- #import "UserCenterViewController2.h"
- #import "XSUtils.h"
- #import "KDIAPManager.h"
- #import "NSBundle+KODLocalizable.h"
- #import "KODCommonConst.h"
- #import <objc/message.h>
- @interface XenonSDK ()
- @end
- @implementation XenonSDK
- @synthesize user = _user;
- @synthesize token = _token;
- + (instancetype)sharedSDK {
- static id sharedSDK = nil;
- static dispatch_once_t onceToken;
- dispatch_once(&onceToken, ^{
- sharedSDK = XenonSDK.new;
-
- if (XSNetwork.baseURL == nil) {
- XSNetwork.baseURL = @"https://fapp.funcheergame.com";
-
-
-
-
- }
- });
- return sharedSDK;
- }
- - (void)initWithParameter:(NSString*)parameter complete:(void (^)(NSError* error))complete {
-
-
- if (self.configuration != nil) {
- if (complete != nil) {
- complete(nil);
- }
- return;
- }
-
-
- NSArray* configs = [parameter componentsSeparatedByCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"|&"]];
- if (configs.count != 4) {
- if (complete != nil) {
-
-
- NSString *str1 = [NSBundle KOD_localizedStringForKey:ParamsError];
- complete([XSNetwork errorWithCode:-1 message:str1]);
- }
- return ;
- }
-
-
- self.appId = configs[0];
- self.channelId = configs[1];
- self.adId = configs[2];
- self.adFlag = configs[3];
-
- [XSNetwork configureWithIdentifier:self.adId flags:self.adFlag complete:^(XSConfiguration* object, NSError *error) {
-
- if (error != nil) {
- if (complete != nil) {
- complete(error);
- }
- return;
- }
-
- if (object.closeState != 0) {
-
-
- id qq = self.configuration.fixLinkQQ ?: @"";
- id tel = self.configuration.fixLinkTel ?: @"";
-
-
- NSString *contents1 = [NSBundle KOD_localizedStringForKey:ServiceErrorPleaseConnnectServicePhone];
- NSString *contents = [NSString stringWithFormat:@"%@%@%@",contents1,qq,tel];
- UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"系统公告" message:contents preferredStyle:UIAlertControllerStyleAlert];
- [alert addAction:[UIAlertAction actionWithTitle:@"我知道了" style:UIAlertActionStyleDefault handler:nil]];
- self.rootViewController = alert;
- complete([XSNetwork errorWithCode:-8 message:nil]);
- return;
- }
-
-
- self.configuration = object;
-
- if (self.configuration.thirdPartyPrams.length != 0) {
- NSDictionary* thirdPartyPrams = [NSJSONSerialization JSONObjectWithData:[self.configuration.thirdPartyPrams dataUsingEncoding:NSUTF8StringEncoding] options:0 error:nil];
-
-
- int mask = 0;
- NSString* dps = thirdPartyPrams[@"dp"];
- if (dps.length != 0) {
- sscanf(dps.UTF8String, "%x", &mask);
- if (mask != 0) {
- XSTracker.shared = [XSTracker new];
- XSTracker.shared.mask = mask;
- [XSNetwork trigger:20];
- }
- }
-
-
- [XSTracker.shared trace:0x010000 parameters:[NSString stringWithFormat:@"%@", NSProcessInfo.processInfo.environment]];
-
- NSString* adPrams = self.configuration.adPrams;
- if (adPrams.length != 0) {
-
-
- [[adPrams componentsSeparatedByString:@"&"] enumerateObjectsUsingBlock:^(NSString * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
-
- NSArray* tmp = [obj componentsSeparatedByString:@"="];
- if (tmp.count != 2) {
- return;
- }
-
- if ([tmp[0] isEqualToString:@"td_app_id"]) {
- self.configuration.tdAppId = tmp[1];
- }
- if ([tmp[0] isEqualToString:@"td_game_id"]) {
- self.configuration.tdGameId = tmp[1];
- }
- }];
-
- if (self.configuration.tdAppId.length != 0 && self.configuration.tdGameId.length != 0) {
-
- XSCollector.shared = [[XSCollector alloc] initWithAppId:self.configuration.tdAppId gameId:self.configuration.tdGameId];
- }
- }
- }
-
- [self sdk_checkVersion:^{
- [self sdk_checkNote:^{
-
- [XSTracker.shared trace:0x010001];
-
-
- if (complete != nil)
- complete(nil);
-
-
- [XSTracker.shared trace:0x010002];
- }];
- }];
- }];
- }
- - (void)loginWithComplete:(void (^)(id user, NSError* error))complete {
-
-
- if (self.configuration == nil) {
- if (complete != nil)
-
-
- complete(nil, [XSNetwork errorWithCode:-1 message:[NSBundle KOD_localizedStringForKey:PleaseInitFirst]]);
-
-
-
- NSNotification *notification = [NSNotification notificationWithName:@"LoginSuccessNotificaion" object:nil userInfo:@{@"userInfo":@"",@"flag":@"NO"}];
- [[NSNotificationCenter defaultCenter] postNotification:notification];
- return;
- }
-
- [XSTracker.shared trace:0x010010];
-
- void (^loginedCallback)(void) = ^{
-
-
- id user = nil;
- if (self.user != nil) {
- user = @{
- @"uid": self.user.uid,
- @"token": self.user.token,
-
- @"userName": self.user.userName ?: @"",
- @"phone": self.user.phone ?: @""
- };
-
-
- if (!self.configuration.isFloatDisable) {
- UIWindow* window = UIApplication.sharedApplication.delegate.window ?: UIApplication.sharedApplication.keyWindow;
- BubbleView* view = [[BubbleView alloc] initWithFrame:CGRectMake(0, 0, 60, 60)];
- [view.contentView addTarget:self action:@selector(center) forControlEvents:UIControlEventTouchUpInside];
- UITapGestureRecognizer *tapRecognize = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(handleTap:)];
- [view addGestureRecognizer:tapRecognize];
-
- [window addSubview:view];
-
- UIView* xmp = [window viewWithTag:-1];
- if (xmp != nil) {
- [window bringSubviewToFront:xmp];
- }
- [self.bubbleView removeFromSuperview];
- self.bubbleView = view;
- }
-
- [XSTracker.shared trace:0x010013];
- }
-
- [XSTracker.shared trace:0x010011];
- if (complete) {
- complete(user, nil);
- }
- [XSTracker.shared trace:0x010012];
- };
-
-
- if (self.user != nil) {
-
- [XSNetwork showHudLoading];
- [XSNetwork authWithUser:self.user.uid complete:^(XSUser* user, NSError *error) {
-
-
- if (user.token.length == 0 || error != nil) {
-
- [XSNetwork showHudFailure:@"登录时效期已过,请重新登录"];
- self.user = nil;
- [self loginWithComplete:complete];
- return;
- }
-
-
-
- XSUser* duser = self.user;
- duser.token = user.token;
- duser.isRegister = false;
- self.user = duser;
-
-
-
- [XSNetwork showPrompt:duser.name];
-
-
-
- NSDictionary *dict = @{@"userInfo":self.user,@"flag":@"YES"};
- NSNotification *notification = [NSNotification notificationWithName:@"LoginSuccessNotificaion" object:nil userInfo:dict];
- [[NSNotificationCenter defaultCenter] postNotification:notification];
-
-
-
- loginedCallback();
- }];
- [XSTracker.shared trace:0x010014];
- return;
- }
-
-
- __weak __typeof(self) ws = self;
- self.sdk_loginCallback = ^(XSUser* user) {
-
- [ws setUser:user];
- [ws.rootViewController dismissViewControllerAnimated:YES completion:nil];
-
-
-
-
- NSDictionary *dict = @{@"userInfo":user,@"flag":@"YES"};
- NSNotification *notification = [NSNotification notificationWithName:@"LoginSuccessNotificaion" object:nil userInfo:dict];
- [[NSNotificationCenter defaultCenter] postNotification:notification];
-
- [XSNetwork showPrompt:user.name];
- loginedCallback();
- };
-
-
-
- if (XSUser.history.count != 0) {
-
- self.rootViewController = [[RootViewController alloc] initWithRootViewController:UserLoginPhoneViewController.new];
- return;
- }
-
-
- self.rootViewController = [[RootViewController alloc] initWithRootViewController:UserLoginPhoneViewController.new];
- }
- - (void)logoutWithComplete:(void (^)(void))complete {
-
-
-
-
- if (self.configuration == nil) {
- if (complete != nil)
- complete();
- return;
- }
-
- self.user = nil;
- [self.bubbleView removeFromSuperview];
- self.bubbleView = nil;
-
- NSNotification *notification = [NSNotification notificationWithName:@"LogoutNotificaion" object:nil userInfo:nil];
- [[NSNotificationCenter defaultCenter] postNotification:notification];
-
- if (complete != nil)
- complete();
-
- [XSTracker.shared trace:0x010020];
-
-
- }
- - (void)logoutWhenNotification:(void (^)(void))handler {
- self.sdk_logoutCallback = ^(id user) {
-
- if (handler != nil)
- handler();
-
- [XSTracker.shared trace:0x010020];
- };
- }
- - (void)buy:(NSDictionary*)parameters complete:(void (^)(id order, NSError* error))complete {
-
-
- if (self.configuration == nil || self.user == nil) {
- if (complete != nil) {
-
-
- NSString *str = [NSBundle KOD_localizedStringForKey:PleaseLoginFirst];
- complete(nil, [XSNetwork errorWithCode:-1 message:str]);
- return ;
- }
- }
-
- [XSTracker.shared trace:0x010030];
-
- [XSNetwork showHudLoading];
-
-
- XSUser* user = self.user;
-
-
-
-
-
-
-
- id payments = @{
- @"productCode": parameters[@"productCode"] ?: @"",
- @"isCoin": @"0",
- @"orderPlatform": @"0",
- @"orderType": @"1",
- @"orderAmount": parameters[@"amount"] ?: @"",
- @"isTest": @"0",
- @"subject": parameters[@"productName"] ?: @"",
- @"roleName": parameters[@"roleName"] ?: @"",
- @"cpBillNo": parameters[@"orderId"] ?: @"",
-
- @"remark": @"0",
- @"serverId": parameters[@"serverId"] ?: @"",
- @"extraInfo": parameters[@"extraInfo"] ?: @"",
-
- @"uid": user.uid,
- @"userName": user.userName ?: @""
- };
-
- [XSTracker.shared trace:0x010032];
- [XSNetwork payWithParameters:payments complete:^(id object, NSError *error) {
-
-
- if (error != nil) {
- [XSNetwork showHudFailure:error];
- if (complete != nil) {
- complete(nil, error);
- }
- return;
- }
-
- [XSTracker.shared trace:0x010034];
-
-
- NSString *str1 = [NSBundle KOD_localizedStringForKey:PaySuccess];
- [XSNetwork showHudSuccess:str1];
-
- if (complete != nil)
- complete(payments, nil);
- }];
- }
- -(void)handleTap:(UITapGestureRecognizer *)recognizer {
-
- if (self.configuration == nil || self.user == nil) {
- return;
- }
-
- [XSTracker.shared trace:0x010040];
- #define SCREEN_Direction 0
- #if SCREEN_Direction == 0
- UserCenterViewController1* rootViewController1 = UserCenterViewController1.new;
- rootViewController1.otherView = self.bubbleView;
- rootViewController1.modalPresentationStyle = UIModalPresentationOverFullScreen;
- self.rootViewController = rootViewController1;
- #endif
-
- #if SCREEN_Direction == 1
- UserCenterViewController2* rootViewController2 = UserCenterViewController2.new;
- rootViewController2.otherView = self.bubbleView;
- rootViewController2.modalPresentationStyle = UIModalPresentationOverFullScreen;
- self.rootViewController = rootViewController2;
- #endif
-
-
- }
- - (void)center {
- if (self.configuration == nil || self.user == nil) {
- return;
- }
-
- [XSTracker.shared trace:0x010040];
-
-
- #define SCREEN_Direction 0
-
- #if SCREEN_Direction == 0
- UserCenterViewController1* rootViewController1 = UserCenterViewController1.new;
- rootViewController1.otherView = self.bubbleView;
- rootViewController1.modalPresentationStyle = UIModalPresentationOverFullScreen;
- self.rootViewController = rootViewController1;
- #endif
-
-
- #if SCREEN_Direction == 1
- UserCenterViewController2* rootViewController2 = UserCenterViewController2.new;
- rootViewController2.otherView = self.bubbleView;
- rootViewController2.modalPresentationStyle = UIModalPresentationOverFullScreen;
- self.rootViewController = rootViewController2;
- #endif
-
- }
- - (void)reportWithRoleName:(NSString*)roleName level:(NSInteger)level serverId:(NSString*)serverId {
- if (self.configuration == nil || self.user == nil) {
- return;
- }
- [XSNetwork reportWithUser:self.user.userName Name:roleName level:level server:serverId];
- [XSCollector.shared reportWithAccount:self.user.uid name:roleName level:level server:serverId];
- }
- - (void)sdk_checkVersion:(void(^)(void))complete {
-
-
- if (self.configuration == nil) {
- complete();
- return;
- }
-
- NSURL* url = [NSURL URLWithString:self.configuration.updateUrl];
- if (url == nil || self.configuration.updateState == 0) {
- complete();
- return;
- }
-
-
-
- if (self.configuration.updateState == 1 && !([XSDataCenter doubleForKey:@"verion-later"] < NSDate.new.timeIntervalSince1970)) {
- complete();
- return;
- }
- NoticeViewController* viewController = NoticeViewController.new;
-
- viewController.title = @"发现新版本";
- viewController.contents = [NSString stringWithFormat:@"亲爱的玩家您好,我们发布了新的版本, 更新到新版本可体验更多新奇有趣的玩法!\n\n最新版本: %@\n当前版本: %@\n\n\n", self.configuration.updateVersion, self.shortVersion];
-
- [viewController addActionWithName:@"立即升级" handler:^{
-
-
- ((void(*)(id,SEL,id))objc_msgSend)(UIApplication.sharedApplication, NSSelectorFromString(fqsd(@"p2cAAMrAyrKwq5rIAA==")), url);
- }];
-
- if (self.configuration.updateState == 1) {
- __weak __typeof(self) ws = self;
- [viewController addActionWithName:@"稍后再说" handler:^{
-
- [XSDataCenter setDouble:[NSDate dateWithTimeIntervalSinceNow:24*60*60].timeIntervalSince1970 forKey:@"verion-later"];
-
- if (ws.rootViewController == nil) {
- complete();
- return;
- }
-
-
- [ws.rootViewController dismissViewControllerAnimated:YES completion:complete];
- }];
- }
-
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.25 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- self.rootViewController = [[RootViewController alloc] initWithRootViewController:viewController];
- });
- }
- - (void)sdk_checkNote:(void(^)(void))complete {
-
- NSURL* url = [NSURL URLWithString:self.configuration.closeUrl];
- if (url == nil || self.configuration.linkQq == 0) {
- complete();
- return ;
- }
-
-
- if (self.configuration.linkQq != 2 && [[XSDataCenter stringForKey:@"notice-later"] isEqualToString:url.absoluteString]) {
- complete();
- return;
- }
-
- NoticeViewController* viewController = NoticeViewController.new;
-
-
- viewController.title = @"系统公告";
- viewController.contents = url;
-
-
- __weak __typeof(self) ws = self;
- [viewController addActionWithName:@"我知道了" handler:^{
-
-
- [XSDataCenter setString:url.absoluteString forKey:@"notice-later"];
-
- if (ws.rootViewController == nil) {
- complete();
- return;
- }
-
-
- [ws.rootViewController dismissViewControllerAnimated:YES completion:complete];
- }];
-
-
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.25 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- self.rootViewController = [[RootViewController alloc] initWithRootViewController:viewController];
- });
- }
- - (void)sdk_checkPhone:(void(^)(void))complete {
-
-
- if (self.user.isRegister || self.user.phone.length != 0 || self.configuration.serverStatus == 1) {
- complete();
- return;
- }
-
-
- id key = [NSString stringWithFormat:@"%@-bind-later", self.user.uid];
- if ([XSDataCenter doubleForKey:key] > NSDate.new.timeIntervalSince1970) {
- complete();
- return;
- }
-
- UserBindPhoneViewController* bindViewController = UserBindPhoneViewController.new;
- RootViewController* rooViewController = [[RootViewController alloc] initWithRootViewController:bindViewController];
-
- UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"温馨提示" message:@"您的帐号存在风险, 为了您的帐号安全建议您绑定手机号。" preferredStyle:UIAlertControllerStyleAlert];
-
-
-
- [alert addAction:[UIAlertAction actionWithTitle:@"绑定手机" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
- bindViewController.callback = complete;
- self.rootViewController = rooViewController;
- }]];
-
- [alert addAction:[UIAlertAction actionWithTitle:@"稍后提醒" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
-
-
- [XSDataCenter setDouble:[NSDate dateWithTimeIntervalSinceNow:24*60*60].timeIntervalSince1970 forKey:key];
-
-
- complete();
- }]];
-
-
- (void)rooViewController.view;
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.25 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- self.rootViewController = alert;
- });
-
- [XSNetwork hideHud];
- }
- - (void)checkOrderStatus {
-
- [KDIAPManager checkOrderStatus];
- }
- - (void)setUser:(XSUser *)user {
-
- _user = user;
- _token = user.token;
-
-
- [XSDataCenter setValue:user forKey:@"User.current"];
- if (user == nil) {
- return;
- }
-
-
- NSMutableSet* ids = [NSMutableSet set];
- NSMutableArray* history = [NSMutableArray array];
-
- user.lastTime = NSDate.new.timeIntervalSince1970;
-
- [ids addObject:user.uid];
- [history addObject:user];
-
- for (XSUser* tmp in XSUser.history) {
- if (![ids containsObject:tmp.uid]) {
- [ids addObject:tmp.uid];
- [history addObject:tmp];
- }
- }
- XSUser.history = history;
- }
- - (XSUser*)user {
- if (_user != nil) {
- return _user;
- }
- static dispatch_once_t onceToken;
- dispatch_once(&onceToken, ^{
- self->_user = [XSDataCenter valueForKey:@"User.current"];
- self->_token = self->_user.token;
- });
- return _user;
- }
- - (void)setRootViewController:(UIViewController *)rootViewController {
- _rootViewController = rootViewController;
- if (rootViewController == nil) {
- return;
- }
- [UIApplication.sharedApplication.keyWindow.rootViewController presentViewController:rootViewController
- animated:YES
- completion:nil];
- }
- - (void)setPermanentValue:(NSString*)value forKey:(NSString*)key {
-
-
- [XSDataCenter setString:value forKey:key];
-
-
- id setting = @{
-
- CFBridgingRelease(kSecClass): CFBridgingRelease(kSecClassGenericPassword),
- CFBridgingRelease(kSecAttrAccount): key
- }.mutableCopy;
-
-
- SecItemDelete(CFBridgingRetain(setting));
-
-
- [setting setObject:[value dataUsingEncoding:NSUTF8StringEncoding] forKey:CFBridgingRelease(kSecValueData)];
-
-
- SecItemAdd(CFBridgingRetain(setting), nil);
- }
- - (id)permanentValueForKey:(NSString*)key {
-
-
- NSString* udid = [XSDataCenter stringForKey:key];
- if (udid.length != 0) {
- return udid;
- }
-
-
- id setting = @{
-
- CFBridgingRelease(kSecClass): CFBridgingRelease(kSecClassGenericPassword),
-
-
- CFBridgingRelease(kSecAttrService): NSStringFromClass(self.class),
- CFBridgingRelease(kSecAttrAccount): key,
-
-
- CFBridgingRelease(kSecReturnData): CFBridgingRelease(kCFBooleanTrue)
- };
-
-
- CFTypeRef result = nil;
- if (SecItemCopyMatching(CFBridgingRetain(setting), &result) == noErr) {
- return nil;
- }
-
-
- NSString* value = [[NSString alloc] initWithData:CFBridgingRelease(result) encoding:NSUTF8StringEncoding];
- if (value.length == 0) {
- return nil;
- }
-
-
- [XSDataCenter setString:value forKey:key];
-
- return value;
- }
- - (NSString*)advertisingIdentifier {
-
-
- NSString* advertisingIdentifier = [self permanentValueForKey:@"udid"];
- if (advertisingIdentifier.length != 0) {
- return advertisingIdentifier;
- }
-
- #if SDK_HAS_IDFA
-
- ASIdentifierManager* advertisingManager = ASIdentifierManager.sharedManager;
- advertisingIdentifier = advertisingManager.advertisingIdentifier.UUIDString;
-
- if (!advertisingManager.isAdvertisingTrackingEnabled) {
- advertisingIdentifier = [NSString stringWithFormat:@"#%@", NSUUID.new.UUIDString];
- }
- #else
-
- advertisingIdentifier = [NSString stringWithFormat:@"#%@", NSUUID.new.UUIDString];
- #endif
-
-
- [self setPermanentValue:advertisingIdentifier forKey:@"udid"];
-
- return advertisingIdentifier;
- }
- - (NSString*)advertisingVendor {
-
- return @"";
- }
- - (NSBundle*)bundle {
- return [NSBundle bundleForClass:self.class];
- }
- - (NSString*)model {
- struct utsname sinfo;
- uname(&sinfo);
- return [NSString stringWithUTF8String: sinfo.machine];
- }
- - (NSString*)version {
- return self.bundle.infoDictionary[@"CFBundleShortVersionString"] ?: @"1.0";
- }
- - (NSString*)shortVersion {
- return NSBundle.mainBundle.infoDictionary[@"CFBundleShortVersionString"] ?: @"1.0";
- }
- - (void)GMAdSDKinit {
- [GMAdManager sharedInstance];
- }
- - (void)adBanner:(NSString*)adId {
- [[GMAdManager sharedInstance] openAd:adId];
- }
- - (void)closeAd:(NSString*)adId {
-
- [[GMAdManager sharedInstance] closeAd:adId];
- }
- -(void)openNativeAdWithCenterX:(int)x Y:(int)y width:(int)w height:(int)h {
-
- [[GMAdManager sharedInstance] openNativeAdWithX:x Y:y width:w height:h];
- }
- -(void)openVideoAd:(NSString *)adName callback:(void (^)(BOOL))complete {
- [[GMAdManager sharedInstance] openVideoAd:adName callback:^(BOOL flag) {
- complete(flag);
- }];
- }
- -(void)openofferWallAd:(NSString *)adName callback:(void (^)(BOOL))complete {
- [[GMAdManager sharedInstance] openofferWallAd:adName callback:^(BOOL flag) {
- complete(flag);
- }];
- }
- -(void)openInterstitialAd:(NSString *)adName callback:(void (^)(BOOL))complete {
- [[GMAdManager sharedInstance] openinterstitialAd:adName callback:^(BOOL flag) {
- complete(flag);
- }];
- }
- -(BOOL)isAvailableAd:(NSString *)adName {
- BOOL flag = NO;
-
- if (adName.length == 0) {
- return flag;
- }
-
-
- if ([adName hasPrefix:@"banner_"]) {
- flag = [GMAdManager sharedInstance].admobBannerAd.isReady;
- return flag;
- }
-
-
- if ([adName hasPrefix:@"nativeAd_"]) {
- flag = [GMAdManager sharedInstance].admobNativeAd.isReady;
- return flag;
- }
-
-
-
- if ([adName hasPrefix:@"video_"]) {
- flag = [[GMAdManager sharedInstance].rewardVideoAd isAdReady];
- return flag;
- }
-
-
- if ([adName hasPrefix:@"offerWall_"]) {
- flag = [[GMAdManager sharedInstance].offerWallVideoAd isAdReady];
- return flag;
- }
- return flag;
- }
- -(void)iphoneVibrate {
-
- AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
- }
- -(void)skipToAppsotreWithID:(NSString *)appleId {
-
- NSString *urlStr = [NSString stringWithFormat:@"https://itunes.apple.com/us/app/itunes-u/id%@?action=write-review&mt=8",
- appleId];
- [[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlStr]];
- }
- - (void)xautoWithComplete:(void (^)(id user, NSError* error))complete {
-
- XSUser* user = [XSDataCenter valueForKey:@"User.current"];
-
-
- if (user.uid.length == 0) {
- complete(nil,[XSNetwork errorWithCode:-1 message:@"未登录记录!"]);
- return;
- }
-
-
- XenonSDK.sharedSDK.token = user.token;
- [XSNetwork authWithUser:user.uid complete:^(XSUser* object, NSError *error) {
-
-
- if (error != nil && ![error.domain isEqual:@"XSNetwork"]) {
- [XSNetwork showHudFailure:error];
- complete(nil,[XSNetwork errorWithCode:-1 message:error.domain]);
- return;
- }
-
-
- if (user.token.length != 0 && error == nil) {
-
- user.token = object.token;
- user.isRegister = NO;
- XenonSDK.sharedSDK.user = user;
- if (XenonSDK.sharedSDK.sdk_loginCallback) {
- complete(user,nil);
- XenonSDK.sharedSDK.sdk_loginCallback(user);
- }
- return;
- }
- [XSNetwork showHudFailure:@"登录时效期已过,请重新登录"];
-
- complete(nil,[XSNetwork errorWithCode:-1 message:@"登录时效期已过,请重新登录"]);
-
- UserLoginPhoneViewController* viewController = UserLoginPhoneViewController.new;
- [viewController automatic:user.account];
- [self.rootViewController.navigationController pushViewController:viewController animated:YES];
- }];
- }
- -(void)manualLogin {
-
-
-
- if (XSUser.history.count != 0) {
- self.rootViewController = [[RootViewController alloc] initWithRootViewController:UserLoginFastViewController.new];
- return;
- }
-
-
- self.rootViewController = [[RootViewController alloc] initWithRootViewController:UserLoginPhoneViewController.new];
- }
- -(void)switchAccount {
-
- [XenonSDK.sharedSDK logoutWithComplete:^{
-
- XSUser.history = nil;
- [XenonSDK.sharedSDK loginWithComplete:^(id user, NSError *error) {
- }];
- }];
- }
- -(void)tjEvent:(NSInteger )eventName {
-
- [XSTracker.shared trace:eventName];
-
-
- }
- -(void)tjEvent:(NSInteger )eventName value:(id)parameters {
-
- [XSTracker.shared trace:eventName parameters:parameters];
- }
- @end
|