Skip to content

Instantly share code, notes, and snippets.

@Calvin-Huang
Created March 14, 2019 21:09
Show Gist options
  • Save Calvin-Huang/a47ae569e19a60d6bc1e8082cb92e8ad to your computer and use it in GitHub Desktop.
Save Calvin-Huang/a47ae569e19a60d6bc1e8082cb92e8ad to your computer and use it in GitHub Desktop.
@interface UserController()
{
dispatch_semaphore_t _sema_use_log;
}
@end
static UserController *_sguco = nil;
@implementation UserController
+(UserController*)sigleton {
if(_sguco!=nil) { return _sguco; }
static dispatch_once_t onceToken_sguco;
dispatch_once(&onceToken_sguco, ^{
_sguco = [[UserController alloc]init];
});
while (_sguco == nil) {}
return _sguco;
}
- (id) init {
self = [super init];
if(self) {
logMessage(@"[dev]", @"%s", __FUNCTION__);
__block NSString* ikeyUid = [NotNilString(self.userProfile[@"ikeyToken"]) copy];
if([ikeyUid length]>10) {
logMessage(@"[dev]", @"%s Logined", __FUNCTION__);
[sysObj triggerUploadFCMToken];
[self startUserCtrlTimer];
}
_sema_use_log = dispatch_semaphore_create(1);
}
return self;
}
#define kLoginInfoInputUserId @"11912e7e353469f9eebd953f2"
#define kLoginInfoInputPasswd @"11912e7e353469f9eebd953f2aac468f"
#define kLoginInfoInputSocialType @"061k0ea85vb7i0fc3n3312ed45f9ee347e429k"
- (void) userLoginWithAccountId:(NSString*)accId
passwd:(NSString*)passwd
socialType:(NSString*)socialType //N:None; FB:facebook; G:GSI
completion:(GeneralCallbackBlock)completion
{
GenenalCallbackGen(completion);
[VIGP2API objectForAllLogInWithTag:0
ikeyAccount:accId
phoneType:@"I" phoneBrand:@"iPhone"
deviceID:[[sysObj DeviceId]lowercaseString]
deviceCreateTime:[[sysObj DeviceCreateTime]copy]
phoneOSVersion:[[sysObj systemVersion] copy]
password:passwd
completion:^(id selfObj, NSInteger tag, id data, NSError *error)
{
NSInteger tokenLen = (error==nil)?[[data valueForKey:@"ikeyToken"] length]:0;
if(error==nil &&
data != nil &&
[data isKindOfClass:[NSDictionary class]] &&
[data count]>2 &&
APIerrCde00Check(data) &&
tokenLen == 36)
{
[UDObj setLoginInfoResult:[data copy]];
[sysObj triggerUploadFCMToken];
[self startUserCtrlTimer];
}
GenenalCallbackCall(data, error);
}];
}
...
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment