facebook登录
This commit is contained in:
parent
8d13a9373f
commit
f1e07cac48
@ -194,6 +194,11 @@
|
||||
BFF5B23D2DF034420044227A /* VPFeedbackViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BFF5B23C2DF034420044227A /* VPFeedbackViewController.swift */; };
|
||||
BFF5B23F2DF0443B0044227A /* VPWebScriptModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BFF5B23E2DF0443B0044227A /* VPWebScriptModel.swift */; };
|
||||
BFF5B2412DF045BF0044227A /* VPRewardsAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = BFF5B2402DF045BF0044227A /* VPRewardsAPI.swift */; };
|
||||
BFF5B2442DF050260044227A /* FacebookCore in Frameworks */ = {isa = PBXBuildFile; productRef = BFF5B2432DF050260044227A /* FacebookCore */; };
|
||||
BFF5B2462DF050260044227A /* FacebookLogin in Frameworks */ = {isa = PBXBuildFile; productRef = BFF5B2452DF050260044227A /* FacebookLogin */; };
|
||||
BFF5B2482DF051D90044227A /* AppDelegate+Thirdparty.swift in Sources */ = {isa = PBXBuildFile; fileRef = BFF5B2472DF051D90044227A /* AppDelegate+Thirdparty.swift */; };
|
||||
BFF5B24A2DF0524D0044227A /* AppDelegate+Open.swift in Sources */ = {isa = PBXBuildFile; fileRef = BFF5B2492DF0524D0044227A /* AppDelegate+Open.swift */; };
|
||||
BFF5B24C2DF052E80044227A /* VPLoginManager+fb.swift in Sources */ = {isa = PBXBuildFile; fileRef = BFF5B24B2DF052E80044227A /* VPLoginManager+fb.swift */; };
|
||||
F939C04AD4003BA127F15C28 /* Pods_Veloria.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 34F57E87E765BF8D72A43DCA /* Pods_Veloria.framework */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
@ -395,6 +400,9 @@
|
||||
BFF5B23C2DF034420044227A /* VPFeedbackViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VPFeedbackViewController.swift; sourceTree = "<group>"; };
|
||||
BFF5B23E2DF0443B0044227A /* VPWebScriptModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VPWebScriptModel.swift; sourceTree = "<group>"; };
|
||||
BFF5B2402DF045BF0044227A /* VPRewardsAPI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VPRewardsAPI.swift; sourceTree = "<group>"; };
|
||||
BFF5B2472DF051D90044227A /* AppDelegate+Thirdparty.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AppDelegate+Thirdparty.swift"; sourceTree = "<group>"; };
|
||||
BFF5B2492DF0524D0044227A /* AppDelegate+Open.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AppDelegate+Open.swift"; sourceTree = "<group>"; };
|
||||
BFF5B24B2DF052E80044227A /* VPLoginManager+fb.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "VPLoginManager+fb.swift"; sourceTree = "<group>"; };
|
||||
E0BDA3570E00C90877E45AA0 /* Pods-VideoPlayer.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-VideoPlayer.debug.xcconfig"; path = "Target Support Files/Pods-VideoPlayer/Pods-VideoPlayer.debug.xcconfig"; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
@ -404,6 +412,8 @@
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
F939C04AD4003BA127F15C28 /* Pods_Veloria.framework in Frameworks */,
|
||||
BFF5B2442DF050260044227A /* FacebookCore in Frameworks */,
|
||||
BFF5B2462DF050260044227A /* FacebookLogin in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@ -448,6 +458,8 @@
|
||||
1B056E212DDAC0FD007EE38D /* AppDelegate.swift */,
|
||||
1B056E282DDAC0FD007EE38D /* SceneDelegate.swift */,
|
||||
BF0FA7312DDEBD6400C9E5F2 /* AppDelegate+Config.swift */,
|
||||
BFF5B2472DF051D90044227A /* AppDelegate+Thirdparty.swift */,
|
||||
BFF5B2492DF0524D0044227A /* AppDelegate+Open.swift */,
|
||||
);
|
||||
path = AppDelegate;
|
||||
sourceTree = "<group>";
|
||||
@ -674,6 +686,7 @@
|
||||
children = (
|
||||
BF0FA6D92DDC5CB600C9E5F2 /* VPLoginManager.swift */,
|
||||
BFF5B2242DEF02080044227A /* VPLoginManager+Apple.swift */,
|
||||
BFF5B24B2DF052E80044227A /* VPLoginManager+fb.swift */,
|
||||
BF0FA6DB2DDC5CD700C9E5F2 /* VPTokenModel.swift */,
|
||||
BFF5B2262DEF022F0044227A /* VPThirdSignModel.swift */,
|
||||
);
|
||||
@ -1182,6 +1195,9 @@
|
||||
);
|
||||
mainGroup = 1B056DEB2DDABE2B007EE38D;
|
||||
minimizedProjectReferenceProxies = 1;
|
||||
packageReferences = (
|
||||
BFF5B2422DF050260044227A /* XCRemoteSwiftPackageReference "facebook-ios-sdk" */,
|
||||
);
|
||||
preferredProjectObjectVersion = 77;
|
||||
productRefGroup = 1B056DF52DDABE2B007EE38D /* Products */;
|
||||
projectDirPath = "";
|
||||
@ -1291,6 +1307,7 @@
|
||||
BF0FA74C2DDF060200C9E5F2 /* VPVideoPlayerViewController.swift in Sources */,
|
||||
BF0FA79B2DE1984B00C9E5F2 /* VPCollectListViewController.swift in Sources */,
|
||||
BF0FA7A32DE1AB1800C9E5F2 /* VPWatchHistoryCell.swift in Sources */,
|
||||
BFF5B24C2DF052E80044227A /* VPLoginManager+fb.swift in Sources */,
|
||||
BF0FA76D2DE053C100C9E5F2 /* VPScrollView.swift in Sources */,
|
||||
BFF5B2202DEEE2C50044227A /* VPLoginContentView.swift in Sources */,
|
||||
1B056E5D2DDACD8E007EE38D /* UIFont+VPAdd.swift in Sources */,
|
||||
@ -1413,6 +1430,7 @@
|
||||
BF0FA73F2DDEF26E00C9E5F2 /* VPHomeSearchButton.swift in Sources */,
|
||||
1B056E512DDACBE5007EE38D /* VPViewController.swift in Sources */,
|
||||
BF0FA7122DDC6D2C00C9E5F2 /* VPHomeModuleItem.swift in Sources */,
|
||||
BFF5B2482DF051D90044227A /* AppDelegate+Thirdparty.swift in Sources */,
|
||||
BFF5AFAC2DE70CE20044227A /* VPMeToolCell.swift in Sources */,
|
||||
BF5E75B32DE465EC00DE9DFE /* Dictionary+SPAdd.swift in Sources */,
|
||||
BF0FA7162DDC78FF00C9E5F2 /* ZKCycleScrollViewFlowLayout.swift in Sources */,
|
||||
@ -1431,6 +1449,7 @@
|
||||
1B056E492DDAC3DF007EE38D /* VPAppTool.swift in Sources */,
|
||||
BFF5AFE62DEEDB7F0044227A /* VPRewardsViewController.swift in Sources */,
|
||||
BF0FA74E2DDF067E00C9E5F2 /* VPVideoPlayViewModel.swift in Sources */,
|
||||
BFF5B24A2DF0524D0044227A /* AppDelegate+Open.swift in Sources */,
|
||||
BFF5B2412DF045BF0044227A /* VPRewardsAPI.swift in Sources */,
|
||||
BF0FA75B2DDF206000C9E5F2 /* VPExplorePlayerCell.swift in Sources */,
|
||||
BF0FA7412DDEFBC700C9E5F2 /* UIScrollView+VPRefresh.swift in Sources */,
|
||||
@ -1683,6 +1702,30 @@
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
|
||||
/* Begin XCRemoteSwiftPackageReference section */
|
||||
BFF5B2422DF050260044227A /* XCRemoteSwiftPackageReference "facebook-ios-sdk" */ = {
|
||||
isa = XCRemoteSwiftPackageReference;
|
||||
repositoryURL = "https://github.com/facebook/facebook-ios-sdk";
|
||||
requirement = {
|
||||
kind = upToNextMajorVersion;
|
||||
minimumVersion = 14.1.0;
|
||||
};
|
||||
};
|
||||
/* End XCRemoteSwiftPackageReference section */
|
||||
|
||||
/* Begin XCSwiftPackageProductDependency section */
|
||||
BFF5B2432DF050260044227A /* FacebookCore */ = {
|
||||
isa = XCSwiftPackageProductDependency;
|
||||
package = BFF5B2422DF050260044227A /* XCRemoteSwiftPackageReference "facebook-ios-sdk" */;
|
||||
productName = FacebookCore;
|
||||
};
|
||||
BFF5B2452DF050260044227A /* FacebookLogin */ = {
|
||||
isa = XCSwiftPackageProductDependency;
|
||||
package = BFF5B2422DF050260044227A /* XCRemoteSwiftPackageReference "facebook-ios-sdk" */;
|
||||
productName = FacebookLogin;
|
||||
};
|
||||
/* End XCSwiftPackageProductDependency section */
|
||||
};
|
||||
rootObject = 1B056DEC2DDABE2B007EE38D /* Project object */;
|
||||
}
|
||||
|
15
Veloria.xcworkspace/xcshareddata/swiftpm/Package.resolved
Normal file
15
Veloria.xcworkspace/xcshareddata/swiftpm/Package.resolved
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
"originHash" : "ca3cf5f8f83d297b47d2cb0edff3e06f294951e2e06fa55cfc82831103499b2a",
|
||||
"pins" : [
|
||||
{
|
||||
"identity" : "facebook-ios-sdk",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/facebook/facebook-ios-sdk",
|
||||
"state" : {
|
||||
"revision" : "c19607d535864533523d1f437c84035e5fb101cf",
|
||||
"version" : "14.1.0"
|
||||
}
|
||||
}
|
||||
],
|
||||
"version" : 3
|
||||
}
|
29
Veloria/AppDelegate/AppDelegate+Open.swift
Normal file
29
Veloria/AppDelegate/AppDelegate+Open.swift
Normal file
@ -0,0 +1,29 @@
|
||||
//
|
||||
// AppDelegate+Open.swift
|
||||
// Veloria
|
||||
//
|
||||
// Created by 湖南秦九 on 2025/6/4.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import FacebookCore
|
||||
|
||||
extension SceneDelegate {
|
||||
|
||||
func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
|
||||
guard let url = URLContexts.first?.url else {
|
||||
return
|
||||
}
|
||||
|
||||
//facebook
|
||||
ApplicationDelegate.shared.application(UIApplication.shared, open: url, sourceApplication: nil, annotation: [UIApplication.OpenURLOptionsKey.annotation])
|
||||
|
||||
|
||||
}
|
||||
|
||||
func scene(_ scene: UIScene, continue userActivity: NSUserActivity) {
|
||||
guard let webpageURL = userActivity.webpageURL else { return }
|
||||
|
||||
}
|
||||
|
||||
}
|
19
Veloria/AppDelegate/AppDelegate+Thirdparty.swift
Normal file
19
Veloria/AppDelegate/AppDelegate+Thirdparty.swift
Normal file
@ -0,0 +1,19 @@
|
||||
//
|
||||
// AppDelegate+Thirdparty.swift
|
||||
// Veloria
|
||||
//
|
||||
// Created by 湖南秦九 on 2025/6/4.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import FacebookCore
|
||||
|
||||
extension AppDelegate {
|
||||
|
||||
func registThirdparty(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) {
|
||||
//facebook
|
||||
ApplicationDelegate.shared.application(application, didFinishLaunchingWithOptions: launchOptions)
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -21,6 +21,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||
|
||||
VPLoginManager.manager.updateUserInfo(completer: nil)
|
||||
|
||||
self.registThirdparty(application, didFinishLaunchingWithOptions: launchOptions)
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,7 @@ class VPLoginContentView: HWPanModalContentView {
|
||||
}()
|
||||
|
||||
private lazy var stackView: UIStackView = {
|
||||
let stackView = UIStackView(arrangedSubviews: [appleButton])
|
||||
let stackView = UIStackView(arrangedSubviews: [facebookButton, appleButton])
|
||||
stackView.axis = .vertical
|
||||
stackView.spacing = 20
|
||||
return stackView
|
||||
@ -75,6 +75,14 @@ class VPLoginContentView: HWPanModalContentView {
|
||||
return button
|
||||
}()
|
||||
|
||||
private lazy var facebookButton: VPLoginButton = {
|
||||
let button = VPLoginButton()
|
||||
button.icon = UIImage(named: "facebook_icon_01")
|
||||
button.title = "Login with Facebook".localized
|
||||
button.addTarget(self, action: #selector(handleFacebookButton), for: .touchUpInside)
|
||||
return button
|
||||
}()
|
||||
|
||||
override init(frame: CGRect) {
|
||||
super.init(frame: frame)
|
||||
|
||||
@ -147,6 +155,10 @@ extension VPLoginContentView {
|
||||
login(type: .apple)
|
||||
}
|
||||
|
||||
@objc private func handleFacebookButton() {
|
||||
login(type: .faceBook)
|
||||
}
|
||||
|
||||
private func login(type: VPLoginManager.LoginType) {
|
||||
VPHUD.show()
|
||||
VPLoginManager.manager.login(type: type, presentingViewController: nil) { [weak self] isFinish in
|
||||
|
59
Veloria/Libs/Login/VPLoginManager+fb.swift
Normal file
59
Veloria/Libs/Login/VPLoginManager+fb.swift
Normal file
@ -0,0 +1,59 @@
|
||||
//
|
||||
// VPLoginManager+fb.swift
|
||||
// Veloria
|
||||
//
|
||||
// Created by 湖南秦九 on 2025/6/4.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import FacebookLogin
|
||||
|
||||
//https://developers.facebook.com/docs/facebook-login/ios?checkpoint_src=any
|
||||
extension VPLoginManager {
|
||||
|
||||
func facebookLogin(presentingViewController: UIViewController?, completer: ((_ model: VPThirdSignModel?) -> Void)?) {
|
||||
|
||||
let loginManager = LoginManager()
|
||||
loginManager.logOut()
|
||||
loginManager.defaultAudience = .everyone
|
||||
|
||||
loginManager.logIn(permissions: ["public_profile", "email"], from: presentingViewController) { result, error in
|
||||
guard error == nil, let result = result else {
|
||||
completer?(nil)
|
||||
return
|
||||
}
|
||||
if result.isCancelled {
|
||||
completer?(nil)
|
||||
return
|
||||
}
|
||||
|
||||
let request = GraphRequest(graphPath: "me", parameters: ["fields" : "id,name,email,picture"], httpMethod: .get)
|
||||
request.start { connection, result, error in
|
||||
guard let result = result as? [String : Any] else {
|
||||
completer?(nil)
|
||||
return
|
||||
}
|
||||
let model = VPThirdSignModel()
|
||||
model.platform = .faceBook
|
||||
model.third_id = result["id"] as? String
|
||||
model.email = result["email"] as? String
|
||||
|
||||
if let picture = result["picture"] as? [String : Any],
|
||||
let data = picture["data"] as? [String : Any],
|
||||
let url = data["url"] as? String
|
||||
{
|
||||
model.avator = url
|
||||
}
|
||||
|
||||
if let name = result["name"] as? String {
|
||||
model.family_name = name
|
||||
} else {
|
||||
model.family_name = result["first_name"] as? String
|
||||
model.giving_name = result["last_name"] as? String
|
||||
}
|
||||
completer?(model)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -50,7 +50,13 @@ class VPLoginManager: NSObject {
|
||||
appleSignLogin { [weak self] model in
|
||||
self?.requestThirdLogin(thirdSignModel: model, completer: completer)
|
||||
}
|
||||
default: break
|
||||
|
||||
case .faceBook:
|
||||
facebookLogin(presentingViewController: presentingViewController) { [weak self] model in
|
||||
self?.requestThirdLogin(thirdSignModel: model, completer: completer)
|
||||
}
|
||||
default:
|
||||
completer?(false)
|
||||
}
|
||||
|
||||
}
|
||||
|
22
Veloria/Source/Assets.xcassets/icon/facebook_icon_01.imageset/Contents.json
vendored
Normal file
22
Veloria/Source/Assets.xcassets/icon/facebook_icon_01.imageset/Contents.json
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "Facebook@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "Facebook@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
BIN
Veloria/Source/Assets.xcassets/icon/facebook_icon_01.imageset/Facebook@2x.png
vendored
Normal file
BIN
Veloria/Source/Assets.xcassets/icon/facebook_icon_01.imageset/Facebook@2x.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 869 B |
BIN
Veloria/Source/Assets.xcassets/icon/facebook_icon_01.imageset/Facebook@3x.png
vendored
Normal file
BIN
Veloria/Source/Assets.xcassets/icon/facebook_icon_01.imageset/Facebook@3x.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
@ -2,8 +2,32 @@
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleURLTypes</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>CFBundleTypeRole</key>
|
||||
<string>Editor</string>
|
||||
<key>CFBundleURLName</key>
|
||||
<string>Facebook</string>
|
||||
<key>CFBundleURLSchemes</key>
|
||||
<array>
|
||||
<string>fb642299232204955</string>
|
||||
</array>
|
||||
</dict>
|
||||
</array>
|
||||
<key>FacebookAppID</key>
|
||||
<string>642299232204955</string>
|
||||
<key>FacebookClientToken</key>
|
||||
<string>b65496dbe4e9f22569d4438f693ae5a2</string>
|
||||
<key>FacebookDisplayName</key>
|
||||
<string>$(PRODUCT_NAME)</string>
|
||||
<key>ITSAppUsesNonExemptEncryption</key>
|
||||
<false/>
|
||||
<key>LSApplicationQueriesSchemes</key>
|
||||
<array>
|
||||
<string>fbapi</string>
|
||||
<string>fb-messenger-share-api</string>
|
||||
</array>
|
||||
<key>UIAppFonts</key>
|
||||
<array>
|
||||
<string>PlayfairDisplay-VariableFont_wght.ttf</string>
|
||||
|
@ -69,6 +69,7 @@
|
||||
"Check in" = "Check in";
|
||||
"Welcome to %@" = "Welcome to %@";
|
||||
"Login with Apple" = "Login with Apple";
|
||||
"Login with Facebook" = "Login with Facebook";
|
||||
"Log In" = "Log In";
|
||||
"Sign Out" = "Sign Out";
|
||||
"Delet Account" = "Delet Account";
|
||||
|
@ -6,5 +6,7 @@
|
||||
<array>
|
||||
<string>Default</string>
|
||||
</array>
|
||||
<key>keychain-access-groups</key>
|
||||
<array/>
|
||||
</dict>
|
||||
</plist>
|
||||
|
Loading…
x
Reference in New Issue
Block a user