// // XSCollector.m // XenonSDK // // Created by SAGESSE on 2019/5/30. // Copyright © 2019 SAGESSE. All rights reserved. // #import "XSCollector.h" #import "TalkingDataGA.h" #import "TalkingDataAppCpa.h" @interface XSCollector () @property (nonatomic, strong) NSString* uid; @property (nonatomic, strong) TDGAAccount* account; @end @implementation XSCollector - (instancetype)initWithAppId:(id)appId gameId:(id)gameId { self = [super init]; [TalkingDataAppCpa setVerboseLogDisabled]; [TalkingDataGA setVerboseLogDisabled]; [TalkingDataAppCpa init:appId withChannelId:gameId]; [TalkingDataGA onStart:gameId withChannelId:@"AppStore"]; return self; } XSCollector* sdk_XSCollector_shared; + (void)setShared:(XSCollector*)tracker { sdk_XSCollector_shared = tracker; } + (XSCollector*)shared { return sdk_XSCollector_shared; } /// Get the unique identifier of talking data. - (NSString*)identifer { return [TalkingDataAppCpa getDeviceId]; } /// Register a user for data analyzer. - (void)registerWithAccount:(NSString*)account name:(NSString*)name { self.uid = account; self.account = [TDGAAccount setAccount:account]; [self.account setAccountName:name]; [TalkingDataAppCpa onRegister:account]; } /// Login a user for data analyzer. - (void)loginWithAccount:(NSString*)account name:(NSString*)name { self.uid = account; self.account = [TDGAAccount setAccount:account]; [self.account setAccountName:name]; [self.account setAccountType:kAccountRegistered]; [TalkingDataAppCpa onLogin:account]; } /// Update account. - (void)reportWithAccount:(NSString*)account name:(NSString*)name level:(NSInteger)level server:(NSString*)server { if (self.uid.length == 0) { return; } TDGAAccount* fa = [TDGAAccount setAccount:self.uid]; [fa setLevel:(int)level]; [fa setAccountName:name]; [fa setGameServer:server]; [fa setAccountType:kAccountRegistered]; [TalkingDataAppCpa onCreateRole:name]; } @end