Commit d23ba692 cgx

完成苹果登录

1 个父辈 4ca62a62
...@@ -97,6 +97,7 @@ ...@@ -97,6 +97,7 @@
D0CFD3CF27FB3B920002982B /* launcher@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = D0CFD3CC27FB3B910002982B /* launcher@2x.png */; }; D0CFD3CF27FB3B920002982B /* launcher@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = D0CFD3CC27FB3B910002982B /* launcher@2x.png */; };
D0CFD3D027FB3B920002982B /* launcher@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = D0CFD3CD27FB3B910002982B /* launcher@3x.png */; }; D0CFD3D027FB3B920002982B /* launcher@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = D0CFD3CD27FB3B910002982B /* launcher@3x.png */; };
D0CFD3D127FB3B920002982B /* launcher.png in Resources */ = {isa = PBXBuildFile; fileRef = D0CFD3CE27FB3B920002982B /* launcher.png */; }; D0CFD3D127FB3B920002982B /* launcher.png in Resources */ = {isa = PBXBuildFile; fileRef = D0CFD3CE27FB3B920002982B /* launcher.png */; };
D0D3826728124E8A005BB219 /* FeedbackController.m in Sources */ = {isa = PBXBuildFile; fileRef = D0D3826628124E8A005BB219 /* FeedbackController.m */; };
D0E65FFA2807A654006562F2 /* NSArray+HYBUnicodeReadable.m in Sources */ = {isa = PBXBuildFile; fileRef = D0E65FF42807A654006562F2 /* NSArray+HYBUnicodeReadable.m */; }; D0E65FFA2807A654006562F2 /* NSArray+HYBUnicodeReadable.m in Sources */ = {isa = PBXBuildFile; fileRef = D0E65FF42807A654006562F2 /* NSArray+HYBUnicodeReadable.m */; };
D0E65FFB2807A654006562F2 /* NSDictionary+HYBUnicodeReadable.m in Sources */ = {isa = PBXBuildFile; fileRef = D0E65FF52807A654006562F2 /* NSDictionary+HYBUnicodeReadable.m */; }; D0E65FFB2807A654006562F2 /* NSDictionary+HYBUnicodeReadable.m in Sources */ = {isa = PBXBuildFile; fileRef = D0E65FF52807A654006562F2 /* NSDictionary+HYBUnicodeReadable.m */; };
D0E65FFC2807A654006562F2 /* NSSet+HYBUnicodeReadable.m in Sources */ = {isa = PBXBuildFile; fileRef = D0E65FF62807A654006562F2 /* NSSet+HYBUnicodeReadable.m */; }; D0E65FFC2807A654006562F2 /* NSSet+HYBUnicodeReadable.m in Sources */ = {isa = PBXBuildFile; fileRef = D0E65FF62807A654006562F2 /* NSSet+HYBUnicodeReadable.m */; };
...@@ -282,6 +283,8 @@ ...@@ -282,6 +283,8 @@
D0CFD3CC27FB3B910002982B /* launcher@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "launcher@2x.png"; sourceTree = "<group>"; }; D0CFD3CC27FB3B910002982B /* launcher@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "launcher@2x.png"; sourceTree = "<group>"; };
D0CFD3CD27FB3B910002982B /* launcher@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "launcher@3x.png"; sourceTree = "<group>"; }; D0CFD3CD27FB3B910002982B /* launcher@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "launcher@3x.png"; sourceTree = "<group>"; };
D0CFD3CE27FB3B920002982B /* launcher.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = launcher.png; sourceTree = "<group>"; }; D0CFD3CE27FB3B920002982B /* launcher.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = launcher.png; sourceTree = "<group>"; };
D0D3826528124E8A005BB219 /* FeedbackController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FeedbackController.h; sourceTree = "<group>"; };
D0D3826628124E8A005BB219 /* FeedbackController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FeedbackController.m; sourceTree = "<group>"; };
D0D7480328118D0B00036379 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/Main.strings"; sourceTree = "<group>"; }; D0D7480328118D0B00036379 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/Main.strings"; sourceTree = "<group>"; };
D0D7480428118D0B00036379 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/LaunchScreen.strings"; sourceTree = "<group>"; }; D0D7480428118D0B00036379 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/LaunchScreen.strings"; sourceTree = "<group>"; };
D0E65FF42807A654006562F2 /* NSArray+HYBUnicodeReadable.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSArray+HYBUnicodeReadable.m"; sourceTree = "<group>"; }; D0E65FF42807A654006562F2 /* NSArray+HYBUnicodeReadable.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSArray+HYBUnicodeReadable.m"; sourceTree = "<group>"; };
...@@ -473,6 +476,7 @@ ...@@ -473,6 +476,7 @@
D04567AD27F6D0F4009F0A82 /* Profile */ = { D04567AD27F6D0F4009F0A82 /* Profile */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
D0D3826428124E34005BB219 /* Feedback */,
D07A4B2E280EC1F100BA0EC0 /* Me */, D07A4B2E280EC1F100BA0EC0 /* Me */,
D07A4B2F280EC21B00BA0EC0 /* Account */, D07A4B2F280EC21B00BA0EC0 /* Account */,
D0CE3D80280A532D00D8B02D /* UserLogin */, D0CE3D80280A532D00D8B02D /* UserLogin */,
...@@ -737,6 +741,15 @@ ...@@ -737,6 +741,15 @@
path = UserLogin; path = UserLogin;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
D0D3826428124E34005BB219 /* Feedback */ = {
isa = PBXGroup;
children = (
D0D3826528124E8A005BB219 /* FeedbackController.h */,
D0D3826628124E8A005BB219 /* FeedbackController.m */,
);
path = Feedback;
sourceTree = "<group>";
};
D0E65FF32807A654006562F2 /* HYBUnicodeReadable */ = { D0E65FF32807A654006562F2 /* HYBUnicodeReadable */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
...@@ -1005,6 +1018,7 @@ ...@@ -1005,6 +1018,7 @@
D0E6600828080F97006562F2 /* SystemSetController.m in Sources */, D0E6600828080F97006562F2 /* SystemSetController.m in Sources */,
D091BBB72808F9DA00487A50 /* BreathTextView.m in Sources */, D091BBB72808F9DA00487A50 /* BreathTextView.m in Sources */,
D04B3DBB27F6F7940022F8DF /* AISleepCoachController.m in Sources */, D04B3DBB27F6F7940022F8DF /* AISleepCoachController.m in Sources */,
D0D3826728124E8A005BB219 /* FeedbackController.m in Sources */,
D027EE2627FB3DC0004BBA61 /* NetLoadingStateView.m in Sources */, D027EE2627FB3DC0004BBA61 /* NetLoadingStateView.m in Sources */,
D0C09EE028007E5F00709D4C /* BreatheController.m in Sources */, D0C09EE028007E5F00709D4C /* BreatheController.m in Sources */,
D0C50B4627FD66FB00DC68F0 /* DSConstUtil.m in Sources */, D0C50B4627FD66FB00DC68F0 /* DSConstUtil.m in Sources */,
......
...@@ -102,9 +102,6 @@ NSString * const NetworkUnableError = @"网络不给力,请检查您的网络 ...@@ -102,9 +102,6 @@ NSString * const NetworkUnableError = @"网络不给力,请检查您的网络
[request addValue:[LoginUtils getSid] forHTTPHeaderField:@"sid"]; [request addValue:[LoginUtils getSid] forHTTPHeaderField:@"sid"];
NSURLSessionDataTask *dataTask = [[DSNetworkTool sharedManager] dataTaskWithRequest:request uploadProgress:nil downloadProgress:nil completionHandler:^(NSURLResponse * _Nonnull response, id _Nullable responseObject, NSError * _Nullable error) { NSURLSessionDataTask *dataTask = [[DSNetworkTool sharedManager] dataTaskWithRequest:request uploadProgress:nil downloadProgress:nil completionHandler:^(NSURLResponse * _Nonnull response, id _Nullable responseObject, NSError * _Nullable error) {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;
NSLog(@"allHeaderFieldsCookie:%@", httpResponse.allHeaderFields[@"Set-Cookie"]);
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO]; [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
if (loadingInfo) { [DSProgressHUD dissmissProgressHUD]; } if (loadingInfo) { [DSProgressHUD dissmissProgressHUD]; }
......
//
// FeedbackController.h
// DreamSleep
//
// Created by peter on 2022/4/22.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
/// 意见反馈
@interface FeedbackController : UIViewController
@end
NS_ASSUME_NONNULL_END
//
// FeedbackController.m
// DreamSleep
//
// Created by peter on 2022/4/22.
//
#import "FeedbackController.h"
@interface FeedbackController ()
@property (strong, nonatomic) UITextView *feedTV;
@property (strong, nonatomic) UICollectionView *imgCollectionView;
@property (strong, nonatomic) UIButton *commitBtn;
@end
@implementation FeedbackController
- (void)viewDidLoad {
[super viewDidLoad];
self.navigationItem.title = @"意见反馈";
self.view.dk_backgroundColorPicker = DKColorPickerWithKey(VCViewBG);
UIButton *myFeedBtn = [UIButton btnWithTitle:@"我的反馈" titleColor:DSWhite font:SysFont(12)];
myFeedBtn.size = CGSizeMake(82, 26);
[myFeedBtn cornerRadius:13];
myFeedBtn.layer.borderColor = DSWhite.CGColor;
myFeedBtn.layer.borderWidth = 1;
[myFeedBtn addTarget:self action:@selector(myFeedAction) forControlEvents:UIControlEventTouchUpInside];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:myFeedBtn];
[self.view addSubview:self.feedTV];
[self.view addSubview:self.imgCollectionView];
[self.view addSubview:self.commitBtn];
[self.feedTV mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(@15);
make.right.equalTo(@-15);
make.top.equalTo(@15);
}];
[self.imgCollectionView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(@15);
make.right.equalTo(@-15);
make.top.equalTo(self.feedTV.mas_bottom).offset(26);
make.height.equalTo(@77);
}];
[self.commitBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(self.view);
make.top.equalTo(self.imgCollectionView.mas_bottom).offset(60);
make.bottom.equalTo(self).offset(-91);
make.width.equalTo(@155);
make.height.equalTo(@40);
}];
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
[self.feedTV endEditing:YES];
}
#pragma mark - Actions
- (void)myFeedAction {
}
- (void)commitAction {
}
#pragma mark - lazy
- (UITextView *)feedTV {
if (!_feedTV) {
_feedTV = [[UITextView alloc] init];
_feedTV.dk_backgroundColorPicker = DKColorPickerWithColors(ColorFromHex(0xf0f0f0), CornerViewDarkColor, DSWhite);
_feedTV.dk_textColorPicker = DKColorPickerWithColors(ColorFromHex(0x777777), DSWhite, DSWhite);
_feedTV.font = SysFont(14);
[_feedTV cornerRadius:12];
[_feedTV becomeFirstResponder];
}
return _feedTV;
}
- (UICollectionView *)imgCollectionView {
if (!_imgCollectionView) {
UICollectionViewLayout *layout = [[UICollectionViewLayout alloc] init];
_imgCollectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
}
return _imgCollectionView;
}
- (UIButton *)commitBtn {
if (!_commitBtn) {
_commitBtn = [UIButton btnWithTitle:@"提交" titleColor:DSWhite font:BoldFont(16) bgColor:BrandColor];
[_commitBtn addTarget:self action:@selector(commitAction) forControlEvents:UIControlEventTouchUpInside];
[_commitBtn cornerRadius:22];
}
return _commitBtn;
}
@end
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
// //
#import "ProfileController.h" #import "ProfileController.h"
#import "FeedbackController.h"
#import "AccountController.h" #import "AccountController.h"
#import "SystemSetController.h" #import "SystemSetController.h"
#import "InviteController.h" #import "InviteController.h"
...@@ -61,6 +62,12 @@ ...@@ -61,6 +62,12 @@
[LoginUtils jumpToLoginControllerWithTarget:self]; [LoginUtils jumpToLoginControllerWithTarget:self];
} }
break; break;
case 1: // 意见反馈入口
{
FeedbackController *feedVC = [FeedbackController new];
[self.navigationController pushViewController:feedVC animated:YES];
}
break;
case 2: // 系统设置入口 case 2: // 系统设置入口
{ {
SystemSetController *sysVC = [SystemSetController new]; SystemSetController *sysVC = [SystemSetController new];
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#import "PrivacyViewController.h" #import "PrivacyViewController.h"
#import <AuthenticationServices/AuthenticationServices.h> #import <AuthenticationServices/AuthenticationServices.h>
#import "UserRequestModel.h" #import "UserRequestModel.h"
#import <UMShare/UMShare.h>
@interface LoginController () <LoginViewDelegate, ASAuthorizationControllerDelegate, ASAuthorizationControllerPresentationContextProviding> @interface LoginController () <LoginViewDelegate, ASAuthorizationControllerDelegate, ASAuthorizationControllerPresentationContextProviding>
@property (strong, nonatomic) LoginView *loginView; @property (strong, nonatomic) LoginView *loginView;
...@@ -44,6 +43,7 @@ ...@@ -44,6 +43,7 @@
- (void)wxLoginAuth:(NSNotification *)noti { - (void)wxLoginAuth:(NSNotification *)noti {
NSString *code = noti.object; NSString *code = noti.object;
// 发送微信登录请求
[UserRequestModel wxLoginWithCode:code completion:^(UserRequestModel * _Nonnull requestModel) { [UserRequestModel wxLoginWithCode:code completion:^(UserRequestModel * _Nonnull requestModel) {
if (requestModel.resCode == DSResCodeSuccess) { if (requestModel.resCode == DSResCodeSuccess) {
[self dismissViewControllerAnimated:YES completion:nil]; [self dismissViewControllerAnimated:YES completion:nil];
...@@ -66,16 +66,6 @@ ...@@ -66,16 +66,6 @@
[WXApi sendReq:req completion:^(BOOL success) { [WXApi sendReq:req completion:^(BOOL success) {
DSLog(@"调起微信成功..."); DSLog(@"调起微信成功...");
}]; }];
// [[UMSocialManager defaultManager] getUserInfoWithPlatform:UMSocialPlatformType_WechatSession currentViewController:nil completion:^(id result, NSError *error) {
// UMSocialUserInfoResponse *resp = result;
//
// if (error) {
// DSLog(@"error:%@", error);
// } else {
// DSLog(@"调起微信成功...");
// }
// }];
} }
break; break;
case 2: // Apple登录 case 2: // Apple登录
...@@ -121,48 +111,21 @@ ...@@ -121,48 +111,21 @@
#pragma mark - ASAuthorizationControllerDelegate #pragma mark - ASAuthorizationControllerDelegate
#pragma mark - 授权成功地回调 #pragma mark - 授权成功地回调
- (void)authorizationController:(ASAuthorizationController *)controller didCompleteWithAuthorization:(ASAuthorization *)authorization API_AVAILABLE(ios(13.0)) { - (void)authorizationController:(ASAuthorizationController *)controller didCompleteWithAuthorization:(ASAuthorization *)authorization API_AVAILABLE(ios(13.0)) {
NSLog(@"%s", __FUNCTION__);
NSLog(@"%@", controller);
NSLog(@"%@", authorization);
NSLog(@"authorization.credential:%@", authorization.credential);
if ([authorization.credential isKindOfClass:[ASAuthorizationAppleIDCredential class]]) { if ([authorization.credential isKindOfClass:[ASAuthorizationAppleIDCredential class]]) {
ASAuthorizationAppleIDCredential *credential = authorization.credential; ASAuthorizationAppleIDCredential *credential = authorization.credential;
NSLog(@"credential = %@", credential);
NSString *state = credential.state;
NSString *userID = credential.user; NSString *userID = credential.user;
NSPersonNameComponents *fullName = credential.fullName;
NSString *email = credential.email;
NSString *authorizationCode = [[NSString alloc] initWithData:credential.authorizationCode encoding:NSUTF8StringEncoding]; // 验证 token NSString *authorizationCode = [[NSString alloc] initWithData:credential.authorizationCode encoding:NSUTF8StringEncoding]; // 验证 token
NSString *identityToken = [[NSString alloc] initWithData:credential.identityToken encoding:NSUTF8StringEncoding]; // 用户 token NSString *identityToken = [[NSString alloc] initWithData:credential.identityToken encoding:NSUTF8StringEncoding]; // 用户 token
ASUserDetectionStatus realUserStatus = credential.realUserStatus; DSLog(@"ios登陆成功:userID: %@\n,authorizationCode: %@\n,identityToken: %@", userID, authorizationCode, identityToken);
NSArray *authorizedScopes = credential.authorizedScopes;
// 发送苹果登录请求
NSLog(@"ios登陆成功 state: %@\nuserID: %@\nfullName: %@\nemail: %@\nauthorizationCode: %@\nidentityToken: %@\nrealUserStatus: %@\nauthorizedScopes: %@", [UserRequestModel appleLoginWithUser:userID identityToken:identityToken authorizationCode:authorizationCode completion:^(UserRequestModel * _Nonnull requestModel) {
state, if (requestModel.resCode == DSResCodeSuccess) {
userID, [self dismissViewControllerAnimated:YES completion:nil];
fullName, } else {
email, [DSProgressHUD showToast:requestModel.errorInfo];
authorizationCode, }
identityToken, }];
@(realUserStatus),
authorizedScopes);
// // 用户登录使用ASAuthorizationAppleIDCredential
// ASAuthorizationAppleIDCredential *appleIDCredential = authorization.credential;
// // 用户ID: user,苹果用户唯一标识,该值在同一个开发者账号下的所有 App 下是一样的。
// NSString *user = appleIDCredential.user;
// // 使用钥匙串的方式保存用户的唯一信息
// NSString *bundleId = [NSBundle mainBundle].bundleIdentifier;
//
// // 验证数据: identityToken , authorizationCode ,用于服务端验证授权请求的合法性。
// NSString *authorizationCode = [[NSString alloc] initWithData:appleIDCredential.authorizationCode encoding:NSUTF8StringEncoding];
// NSString *identityToken = [[NSString alloc] initWithData:appleIDCredential.identityToken encoding:NSUTF8StringEncoding];
//
// NSLog(@"user:%@, bundleId:%@, authorizationCode:%@, identityToken:%@", user, bundleId, authorizationCode, identityToken);
// 通过钥匙串保存用户授权信息
// [SAMKeychain setPassword:user forService:bundleId account:ShareCurrentIdentifier];
} else if ([authorization.credential isKindOfClass:[ASPasswordCredential class]]) { } else if ([authorization.credential isKindOfClass:[ASPasswordCredential class]]) {
// 用户登录使用现有的密码凭证 // 用户登录使用现有的密码凭证
ASPasswordCredential *passwordCredential = authorization.credential; ASPasswordCredential *passwordCredential = authorization.credential;
...@@ -170,17 +133,14 @@ ...@@ -170,17 +133,14 @@
NSString *user = passwordCredential.user; NSString *user = passwordCredential.user;
// 密码凭证对象的密码 // 密码凭证对象的密码
NSString *password = passwordCredential.password; NSString *password = passwordCredential.password;
DSLog(@"user:%@, password:%@", user, password);
NSLog(@"user:%@, password:%@", user, password);
} else { } else {
NSLog(@"授权信息均不符"); DSLog(@"授权信息均不符");
} }
} }
#pragma mark - 授权失败的回调 #pragma mark - 授权失败的回调
- (void)authorizationController:(ASAuthorizationController *)controller didCompleteWithError:(NSError *)error API_AVAILABLE(ios(13.0)) { - (void)authorizationController:(ASAuthorizationController *)controller didCompleteWithError:(NSError *)error API_AVAILABLE(ios(13.0)) {
NSLog(@"%s", __FUNCTION__);
NSLog(@"错误信息:%@", error);
NSString *errorMsg = nil; NSString *errorMsg = nil;
switch (error.code) { switch (error.code) {
case ASAuthorizationErrorCanceled: case ASAuthorizationErrorCanceled:
...@@ -202,7 +162,7 @@ ...@@ -202,7 +162,7 @@
errorMsg = @"ASAuthorizationErrorNotInteractive"; errorMsg = @"ASAuthorizationErrorNotInteractive";
break; break;
} }
NSLog(@"controller requests:%@, errorMsg:%@", controller.authorizationRequests, errorMsg); DSLog(@"controller requests:%@, errorMsg:%@", controller.authorizationRequests, errorMsg);
} }
#pragma mark - ASAuthorizationControllerPresentationContextProviding #pragma mark - ASAuthorizationControllerPresentationContextProviding
......
...@@ -15,7 +15,9 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -15,7 +15,9 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, assign) BOOL gender; @property (nonatomic, assign) BOOL gender;
@property (nonatomic, copy) NSString *birthday; @property (nonatomic, copy) NSString *birthday;
@property (nonatomic, assign) int user_id; @property (nonatomic, assign) int user_id;
// 登录token
@property (nonatomic, copy) NSString *token; @property (nonatomic, copy) NSString *token;
// 获取后每次发送请求存放到请求头
@property (nonatomic, copy) NSString *sid; @property (nonatomic, copy) NSString *sid;
@property (nonatomic, copy) NSString *user_name; @property (nonatomic, copy) NSString *user_name;
@property (nonatomic, copy) NSString *face_img; @property (nonatomic, copy) NSString *face_img;
......
...@@ -20,6 +20,12 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -20,6 +20,12 @@ NS_ASSUME_NONNULL_BEGIN
/// @param completion completion /// @param completion completion
+ (NSURLSessionDataTask *)wxLoginWithCode:(NSString *)code completion:(void (^)(UserRequestModel *requestModel))completion; + (NSURLSessionDataTask *)wxLoginWithCode:(NSString *)code completion:(void (^)(UserRequestModel *requestModel))completion;
/// 苹果登录请求
+ (NSURLSessionDataTask *)appleLoginWithUser:(NSString *)user
identityToken:(NSString *)identityToken
authorizationCode:(NSString *)authorizationCode
completion:(void (^)(UserRequestModel *requestModel))completion;
/// 用户退出登录接口 /// 用户退出登录接口
/// @param completion completion /// @param completion completion
+ (NSURLSessionDataTask *)layoutRequestWithCompletion:(void (^)(UserRequestModel *requestModel))completion; + (NSURLSessionDataTask *)layoutRequestWithCompletion:(void (^)(UserRequestModel *requestModel))completion;
......
...@@ -30,6 +30,30 @@ ...@@ -30,6 +30,30 @@
}]; }];
} }
+ (NSURLSessionDataTask *)appleLoginWithUser:(NSString *)user
identityToken:(NSString *)identityToken
authorizationCode:(NSString *)authorizationCode
completion:(void (^)(UserRequestModel *requestModel))completion
{
UserRequestModel * requestModel = [[UserRequestModel alloc] init];
NSString *api = @"verify_sign_with_appleid";
NSString *argStr = [NSString stringWithFormat:@"mutation{%@(user_id:\"%@\",identity_token:\"%@\",authorization_code:\"%@\")}", api, user, identityToken, authorizationCode];
return [self httpPostBodyRequestWithAPI:api params:@{@"query" : argStr} view:nil hasNetActivity:YES loadingInfo:nil hasFailInfo:YES success:^(NSDictionary * _Nonnull apiDic) {
DSLog(@"苹果登录接口apiDic:%@", apiDic);
requestModel.resCode = DSResCodeSuccess;
NSDictionary *resultDic = apiDic[@"result"];
UserModel *userModel = [UserModel yy_modelWithJSON:resultDic];
DSLog(@"userModel:%@", userModel.debugDescription);
// 保存用户信息
[LoginUtils saveUserLoginData:userModel];
completion(requestModel);
} failure:^(id _Nonnull failureInfo) {
requestModel.resCode = DSResCodeNetFail;
requestModel.errorInfo = failureInfo;
completion(requestModel);
}];
}
+ (NSURLSessionDataTask *)layoutRequestWithCompletion:(void (^)(UserRequestModel *requestModel))completion + (NSURLSessionDataTask *)layoutRequestWithCompletion:(void (^)(UserRequestModel *requestModel))completion
{ {
UserRequestModel * requestModel = [[UserRequestModel alloc] init]; UserRequestModel * requestModel = [[UserRequestModel alloc] init];
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!