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
345e0921
Commit
345e0921
authored
Jun 03, 2024
by
Steven杜宇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
// 苹果登录防止重复点击
parent
d701d73a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
3 deletions
+8
-3
YHAppleLoginManager.swift
...sses/Modules/AppleLogin(苹果登录)/M/YHAppleLoginManager.swift
+8
-3
No files found.
galaxy/galaxy/Classes/Modules/AppleLogin(苹果登录)/M/YHAppleLoginManager.swift
View file @
345e0921
...
@@ -12,12 +12,15 @@ import AuthenticationServices
...
@@ -12,12 +12,15 @@ import AuthenticationServices
class
YHAppleLoginManager
:
NSObject
{
class
YHAppleLoginManager
:
NSObject
{
static
let
shared
=
YHAppleLoginManager
()
static
let
shared
=
YHAppleLoginManager
()
let
viewModel
=
YHAppleLoginViewModel
()
let
viewModel
=
YHAppleLoginViewModel
()
// 防止苹果登录按钮反复点击
var
isAppleLoginBtnEnabled
=
true
var
success
:
(([
String
:
Any
])
->
())?
var
success
:
(([
String
:
Any
])
->
())?
func
appleLogin
()
{
func
appleLogin
()
{
if
!
isAppleLoginBtnEnabled
{
return
}
let
appleIDProvider
=
ASAuthorizationAppleIDProvider
()
let
appleIDProvider
=
ASAuthorizationAppleIDProvider
()
let
request
=
appleIDProvider
.
createRequest
()
let
request
=
appleIDProvider
.
createRequest
()
request
.
requestedScopes
=
[
.
fullName
,
.
email
]
request
.
requestedScopes
=
[
.
fullName
,
.
email
]
...
@@ -25,6 +28,7 @@ class YHAppleLoginManager: NSObject {
...
@@ -25,6 +28,7 @@ class YHAppleLoginManager: NSObject {
vc
.
delegate
=
self
vc
.
delegate
=
self
vc
.
presentationContextProvider
=
self
vc
.
presentationContextProvider
=
self
vc
.
performRequests
()
vc
.
performRequests
()
isAppleLoginBtnEnabled
=
false
}
}
}
}
...
@@ -32,6 +36,7 @@ extension YHAppleLoginManager: ASAuthorizationControllerDelegate, ASAuthorizatio
...
@@ -32,6 +36,7 @@ extension YHAppleLoginManager: ASAuthorizationControllerDelegate, ASAuthorizatio
func
authorizationController
(
controller
:
ASAuthorizationController
,
didCompleteWithAuthorization
authorization
:
ASAuthorization
)
{
func
authorizationController
(
controller
:
ASAuthorizationController
,
didCompleteWithAuthorization
authorization
:
ASAuthorization
)
{
isAppleLoginBtnEnabled
=
true
var
userId
=
""
var
userId
=
""
var
email
=
""
var
email
=
""
var
fullName
=
""
var
fullName
=
""
...
@@ -74,7 +79,7 @@ extension YHAppleLoginManager: ASAuthorizationControllerDelegate, ASAuthorizatio
...
@@ -74,7 +79,7 @@ extension YHAppleLoginManager: ASAuthorizationControllerDelegate, ASAuthorizatio
func
authorizationController
(
controller
:
ASAuthorizationController
,
didCompleteWithError
error
:
Error
)
{
func
authorizationController
(
controller
:
ASAuthorizationController
,
didCompleteWithError
error
:
Error
)
{
printLog
(
"Apple login FAILED:
\(
error
.
localizedDescription
)
"
)
printLog
(
"Apple login FAILED:
\(
error
.
localizedDescription
)
"
)
isAppleLoginBtnEnabled
=
true
if
error
is
ASAuthorizationError
{
if
error
is
ASAuthorizationError
{
let
err
=
error
as!
ASAuthorizationError
let
err
=
error
as!
ASAuthorizationError
// 在这里处理 AuthenticationError
// 在这里处理 AuthenticationError
...
...
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