Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
galaxy-iOS
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mobile-group
galaxy-iOS
Commits
523096a4
Commit
523096a4
authored
May 30, 2024
by
Steven杜宇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
一键登录
parent
b88bc567
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
66 additions
and
33 deletions
+66
-33
YHAppleLoginManager.swift
...sses/Modules/AppleLogin(苹果登录)/C/YHAppleLoginManager.swift
+2
-1
YHOneKeyLoginManager.swift
...sses/Modules/AutoLogin(一键登录)/M/YHOneKeyLoginManager.swift
+64
-32
No files found.
galaxy/galaxy/Classes/Modules/AppleLogin(苹果登录)/C/YHAppleLoginManager.swift
View file @
523096a4
...
@@ -54,7 +54,8 @@ extension YHAppleLoginManager: ASAuthorizationControllerDelegate, ASAuthorizatio
...
@@ -54,7 +54,8 @@ extension YHAppleLoginManager: ASAuthorizationControllerDelegate, ASAuthorizatio
}
}
func
authorizationController
(
controller
:
ASAuthorizationController
,
didCompleteWithError
error
:
Error
)
{
func
authorizationController
(
controller
:
ASAuthorizationController
,
didCompleteWithError
error
:
Error
)
{
printLog
(
"FAILED:
\(
error
.
localizedDescription
)
"
)
YHHUD
.
flash
(
message
:
"苹果登录失败 原因:
\(
error
.
localizedDescription
)
"
)
printLog
(
"Apple login FAILED:
\(
error
.
localizedDescription
)
"
)
}
}
func
presentationAnchor
(
for
controller
:
ASAuthorizationController
)
->
ASPresentationAnchor
{
func
presentationAnchor
(
for
controller
:
ASAuthorizationController
)
->
ASPresentationAnchor
{
...
...
galaxy/galaxy/Classes/Modules/AutoLogin(一键登录)/M/YHOneKeyLoginManager.swift
View file @
523096a4
...
@@ -12,21 +12,19 @@ import AVFoundation
...
@@ -12,21 +12,19 @@ import AVFoundation
class
YHOneKeyLoginManager
{
class
YHOneKeyLoginManager
{
static
let
shared
=
YHOneKeyLoginManager
()
static
let
shared
=
YHOneKeyLoginManager
()
// 是否加速取号成功
var
isAccelerateGetPhontNumberSuccess
=
false
}
}
extension
YHOneKeyLoginManager
{
extension
YHOneKeyLoginManager
{
func
oneKeyLogin
()
{
func
oneKeyLogin
()
{
YHOneKeyLoginManager
.
shared
.
checkIsSupportOneKeyLogin
{
YHOneKeyLoginManager
.
shared
.
checkIsSupportOneKeyLogin
{
support
in
support
in
if
!
support
{
if
!
support
{
YHHUD
.
flash
(
message
:
"不支持一键登录"
)
YHHUD
.
flash
(
message
:
"不支持一键登录"
)
// 跳转APP自定义登录界面
// 跳转APP自定义登录界面
let
vc
=
UINavigationController
(
rootVC
:
YHOtherLoginViewController
())
self
.
enterAppLoginPage
(
isFromOneKeyPage
:
false
)
vc
.
modalPresentationStyle
=
.
fullScreen
UIViewController
.
current
?
.
present
(
vc
,
animated
:
true
)
return
return
}
}
// 支持一键登录
// 支持一键登录
...
@@ -34,6 +32,19 @@ extension YHOneKeyLoginManager {
...
@@ -34,6 +32,19 @@ extension YHOneKeyLoginManager {
}
}
}
}
// 进入App自己设计的主登录界面
// @param isFromOneKeyPage:是否是从一键登录界面进入
func
enterAppLoginPage
(
isFromOneKeyPage
:
Bool
)
{
if
isFromOneKeyPage
{
let
vc
=
YHOtherLoginViewController
()
UIViewController
.
current
?
.
navigationController
?
.
pushViewController
(
vc
,
animated
:
true
)
return
}
let
vc
=
UINavigationController
(
rootVC
:
YHOtherLoginViewController
())
vc
.
modalPresentationStyle
=
.
fullScreen
UIViewController
.
current
?
.
present
(
vc
,
animated
:
true
)
}
func
getSDKVersion
()
->
String
{
func
getSDKVersion
()
->
String
{
return
TXCommonHandler
.
sharedInstance
()
.
getVersion
()
return
TXCommonHandler
.
sharedInstance
()
.
getVersion
()
}
}
...
@@ -42,27 +53,13 @@ extension YHOneKeyLoginManager {
...
@@ -42,27 +53,13 @@ extension YHOneKeyLoginManager {
TXCommonHandler
.
sharedInstance
()
.
setAuthSDKInfo
(
YhConstant
.
Alipay
.
kAliLoginSecretKey
)
{
TXCommonHandler
.
sharedInstance
()
.
setAuthSDKInfo
(
YhConstant
.
Alipay
.
kAliLoginSecretKey
)
{
dict
in
dict
in
printLog
(
dict
)
printLog
(
"设置secretKey结果:
\(
dict
)
"
)
}
TXCommonHandler
.
sharedInstance
()
.
accelerateLoginPage
(
withTimeout
:
10.0
)
{
dic
in
guard
let
code
=
dic
[
"resultCode"
]
as?
String
else
{
// 进行加速登录 方便点击登录时提速
printLog
(
"加速取号失败"
)
TXCommonHandler
.
sharedInstance
()
.
accelerateLoginPage
(
withTimeout
:
10.0
)
{
YHOneKeyLoginManager
.
shared
.
isAccelerateGetPhontNumberSuccess
=
false
dic
in
return
printLog
(
"加速登录结果:
\(
dic
)
"
)
}
}
if
code
!=
PNSCodeSuccess
{
printLog
(
"加速取号失败"
)
YHOneKeyLoginManager
.
shared
.
isAccelerateGetPhontNumberSuccess
=
false
return
}
// 加速取号成功
printLog
(
"加速取号成功"
)
YHOneKeyLoginManager
.
shared
.
isAccelerateGetPhontNumberSuccess
=
true
}
}
}
}
...
@@ -71,6 +68,8 @@ extension YHOneKeyLoginManager {
...
@@ -71,6 +68,8 @@ extension YHOneKeyLoginManager {
TXCommonHandler
.
sharedInstance
()
.
checkEnvAvailable
(
with
:
.
loginToken
)
{
TXCommonHandler
.
sharedInstance
()
.
checkEnvAvailable
(
with
:
.
loginToken
)
{
dict
in
dict
in
printLog
(
"checkEnvAvailable:
\(
String
(
describing
:
dict
)
)
"
)
if
let
resultCode
=
dict
?[
"resultCode"
]
as?
String
,
resultCode
==
PNSCodeSuccess
{
if
let
resultCode
=
dict
?[
"resultCode"
]
as?
String
,
resultCode
==
PNSCodeSuccess
{
support
?(
true
)
support
?(
true
)
}
else
{
}
else
{
...
@@ -84,9 +83,15 @@ extension YHOneKeyLoginManager {
...
@@ -84,9 +83,15 @@ extension YHOneKeyLoginManager {
// 3. 开始一键登录流程
// 3. 开始一键登录流程
//3.2 调用获取登录Token接口,可以立马弹起授权页,model的创建需要放在主线程
//3.2 调用获取登录Token接口,可以立马弹起授权页,model的创建需要放在主线程
let
model
=
self
.
createLoginUIModel
()
let
model
=
self
.
createLoginUIModel
()
TXCommonHandler
.
sharedInstance
()
.
getLoginToken
(
withTimeout
:
10.0
,
controller
:
UIViewController
.
current
!
,
model
:
model
)
{
YHHUD
.
show
(
.
progress
(
message
:
"加载中..."
))
TXCommonHandler
.
sharedInstance
()
.
getLoginToken
(
withTimeout
:
3.0
,
controller
:
UIViewController
.
current
!
,
model
:
model
)
{
dict
in
dict
in
DispatchQueue
.
main
.
async
{
YHHUD
.
hide
()
}
guard
let
code
=
dict
[
"resultCode"
]
as?
String
else
{
guard
let
code
=
dict
[
"resultCode"
]
as?
String
else
{
printLog
(
dict
)
printLog
(
dict
)
return
return
...
@@ -94,8 +99,9 @@ extension YHOneKeyLoginManager {
...
@@ -94,8 +99,9 @@ extension YHOneKeyLoginManager {
if
code
==
PNSCodeSuccess
{
if
code
==
PNSCodeSuccess
{
// 点击登录按钮获取登录Token成功回调
// 点击登录按钮获取登录Token成功回调
guard
let
token
=
dict
[
"token"
]
as?
String
else
{
guard
let
token
=
dict
[
"token"
]
as?
String
,
!
token
.
isEmpty
else
{
printLog
(
"获取登录Token失败"
)
printLog
(
"获取登录Token失败"
)
return
return
}
}
printLog
(
"oneKeyLogin token:
\(
token
)
"
)
printLog
(
"oneKeyLogin token:
\(
token
)
"
)
...
@@ -124,9 +130,17 @@ extension YHOneKeyLoginManager {
...
@@ -124,9 +130,17 @@ extension YHOneKeyLoginManager {
// 以下是处理一键登录异常
// 以下是处理一键登录异常
if
code
==
PNSCodeLoginControllerPresentSuccess
{
if
code
==
PNSCodeLoginControllerPresentFailed
{
printLog
(
"弹起授权页失败"
)
// 此时一键登录界面未显示
self
.
enterAppLoginPage
(
isFromOneKeyPage
:
true
)
}
else
if
code
==
PNSCodeLoginControllerPresentSuccess
{
printLog
(
"弹起授权页成功"
)
printLog
(
"弹起授权页成功"
)
}
else
if
code
==
PNSCodeCallPreLoginInAuthPage
{
printLog
(
"授权页已加载时不允许调用加速或预取号接口"
)
}
else
if
code
==
PNSCodeLoginControllerClickCancel
{
}
else
if
code
==
PNSCodeLoginControllerClickCancel
{
printLog
(
"点击了授权页的返回"
)
printLog
(
"点击了授权页的返回"
)
...
@@ -147,11 +161,27 @@ extension YHOneKeyLoginManager {
...
@@ -147,11 +161,27 @@ extension YHOneKeyLoginManager {
}
else
if
code
==
PNSCodeLoginControllerClickProtocol
{
}
else
if
code
==
PNSCodeLoginControllerClickProtocol
{
printLog
(
"点击了协议富文本"
)
printLog
(
"点击了协议富文本"
)
}
else
if
code
==
PNSCodeLoginClickPrivacyAlertView
{
printLog
(
"点击一键登录拉起授权页二次弹窗"
)
}
else
if
code
==
PNSCodeLoginPrivacyAlertViewClose
{
printLog
(
"点击隐私协议二次弹窗关闭"
)
}
else
if
code
==
PNSCodeLoginPrivacyAlertViewClickContinue
{
printLog
(
"隐私协议二次弹窗点击确认并继续"
)
}
else
if
code
==
PNSCodeLoginPrivacyAlertViewPrivacyContentClick
{
printLog
(
"点击隐私协议二次弹窗上的协议富文本文字"
)
}
else
if
code
==
PNSCodeLoginControllerSuspendDisMissVC
{
printLog
(
"中断页面消失的时候,也就是suspendDisMissVC设置为YES的时候"
)
}
else
{
printLog
(
"其他错误:
\(
dict
)
"
)
self
.
enterAppLoginPage
(
isFromOneKeyPage
:
true
)
}
}
}
}
}
}
func
createLoginUIModel
()
->
TXCustomModel
{
func
createLoginUIModel
()
->
TXCustomModel
{
...
@@ -212,9 +242,11 @@ extension YHOneKeyLoginManager {
...
@@ -212,9 +242,11 @@ extension YHOneKeyLoginManager {
}
}
// 改变登录方式
// 改变登录方式
videoBgView
.
changeLoginBlock
=
{
videoBgView
.
changeLoginBlock
=
{
let
vc
=
YHOtherLoginViewController
()
[
weak
self
]
in
UIViewController
.
current
?
.
navigationController
?
.
pushViewController
(
vc
,
animated
:
true
)
guard
let
self
=
self
else
{
return
}
self
.
enterAppLoginPage
(
isFromOneKeyPage
:
true
)
}
}
model
.
customViewBlock
=
{
model
.
customViewBlock
=
{
superCustomView
in
superCustomView
in
superCustomView
.
insertSubview
(
videoBgView
,
at
:
0
)
superCustomView
.
insertSubview
(
videoBgView
,
at
:
0
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment