cdts/xdts-ios 3/TreeHole/CYHResetCode/CYH/GeTuiService(个推)/GeTuiServiceTool+QuickAuthorize.m
2023-07-27 09:20:00 +08:00

114 lines
3.9 KiB
Objective-C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// GeTuiServiceTool+QuickAuthorize.m
// TreeHole
//
// Created by iOS on 2023/2/3.
// Copyright © 2023 CYH. All rights reserved.
//
#import "GeTuiServiceTool+QuickAuthorize.h"
#import <GeYanSdk/GeYanSdk.h>
//#import <objc/runtime.h>
//#if IS_DEBUG
//#define GeTuiQuickAuthorizeAppID @"poCj93sZUa8gmaiuBm9hO3"
//#define GETUI_APPKEY @"DiO4uhHEiI6st78cJyuLs6"
//#define GETUI_APPSECRET @"iFksMbXAyI9hzvd3nVuCk4"
//#else
//#define GeTuiQuickAuthorizeAppID @"poCj93sZUa8gmaiuBm9hO3"
//#define GETUI_APPKEY @"DiO4uhHEiI6st78cJyuLs6"
//#define GETUI_APPSECRET @"iFksMbXAyI9hzvd3nVuCk4"
//#endif
#define GeTuiQuickAuthorizeAppID @"poCj93sZUa8gmaiuBm9hO3"
@implementation GeTuiServiceTool (QuickAuthorize)
//- (instancetype)initWithServiceAppId:(NSString *)appId {
// if (self = [super init]) {
//
// }
// return self;
//}
///初始化
+ (void)GT_QuickAuthorizeLoginSetupService:(void(^)(BOOL isSuccess, NSError * _Nullable error, NSString * _Nullable gyUid))complete {
// __block NSInteger index = 0;//计数,3次
[GeYanSdk startWithAppId:GeTuiQuickAuthorizeAppID withTimeout:10 withCallback:^(BOOL isSuccess, NSError * _Nullable error, NSString * _Nullable gyUid) {
if (isSuccess) {//初始化成功
//设置超时时间,默认10秒
[GeYanSdk setEloginTimeout:7];
complete(YES, error, gyUid);
return;
}
//初始化不成功
// index++;
// if (index < 3) {
// [self GT_QuickAuthorizeLoginSetupService:complete];
// return;
// }
///不成功
complete(NO, error, gyUid);
}];
}
///预登录, 很耗时,越早调用越好(启动时调用)
+ (void)GT_QuickAuthorizePreLoginGetToken:(void(^)(BOOL isSuccess, NSDictionary *tokenDic))complete {
[GeYanSdk preGetToken:^(NSDictionary * _Nullable verifyDictionary) {
if ([verifyDictionary.allKeys containsObject:@"code"]) {
NSNumber *code = verifyDictionary[@"code"];
if (code.intValue == 30000) {
/*成功
verifyDictionary: {
code = 30000; //30000操作成功 其他错误码需参考《状态码汇总》
expiredTime = 120; //结果有效时长,秒
number = "152****0533"; //当前设备的手机号,带掩码
operatorType = 1; //0未知 1移动 2联通 3电信
msg = "操作成功";
gyuid = "gtc_dbf8471ad1ef4681bf9928a446784aa535";
processID = d3729d0402e358bfaabdb59670ee9143;
}
*/
complete(YES, verifyDictionary);
return;
}
}
/*失败
verifyDictionary: {
code = 30005;
errorCode = "-40001";
metadata = { //运营商错误信息
desc = "无网络";
resultCode = 200022;
traceId = c542db408fe3438028b644d451d479d3;
};
operatorType = 1;
msg = "运营商返回失败";
gyuid = gtc_dbf8471ad1ef4681bf9928a446784aa535;
processID = f676bc541499282fda1f795d390c5f5c;
}
*/
complete(NO, verifyDictionary);
}];
}
///一键登录预取号拿到的token是否还在有效期
+ (BOOL)isPreGettedTokenValidate {
return [GeYanSdk isPreGettedTokenValidate];
}
///登录
- (void)GT_QuickLoginWithGyuid:(NSString *)gyuid preLoginToken:(NSString *)preToken {
//1.(用gyuid+Token+idfa)发请求给后端去登录 - @"login"
//2.判断用户之前是否注册过,新用户->跳设置资料页面;老用户直接登录IM进入首页
}
@end