facebook登录

This commit is contained in:
zeng 2025-04-30 14:49:22 +08:00
parent 9a26c4ac7f
commit 9a50ca2fdc
9 changed files with 149 additions and 2 deletions

View File

@ -7,6 +7,8 @@
objects = {
/* Begin PBXBuildFile section */
1B384A992DC1CFE800F5B1A2 /* FacebookCore in Frameworks */ = {isa = PBXBuildFile; productRef = 1B384A982DC1CFE800F5B1A2 /* FacebookCore */; };
1B384A9B2DC1CFE800F5B1A2 /* FacebookLogin in Frameworks */ = {isa = PBXBuildFile; productRef = 1B384A9A2DC1CFE800F5B1A2 /* FacebookLogin */; };
91D08C5AEAE459A3B8EA48C6 /* Pods_MoviaBox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A81436A54285C9EE97EEBC50 /* Pods_MoviaBox.framework */; };
/* End PBXBuildFile section */
@ -46,6 +48,8 @@
buildActionMask = 2147483647;
files = (
91D08C5AEAE459A3B8EA48C6 /* Pods_MoviaBox.framework in Frameworks */,
1B384A992DC1CFE800F5B1A2 /* FacebookCore in Frameworks */,
1B384A9B2DC1CFE800F5B1A2 /* FacebookLogin in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -139,6 +143,7 @@
mainGroup = 1DBC40502DA4EDFC0093FCB0;
minimizedProjectReferenceProxies = 1;
packageReferences = (
1B384A972DC1CFE800F5B1A2 /* XCRemoteSwiftPackageReference "facebook-ios-sdk" */,
);
preferredProjectObjectVersion = 77;
productRefGroup = 1DBC405A2DA4EDFC0093FCB0 /* Products */;
@ -446,6 +451,30 @@
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
/* Begin XCRemoteSwiftPackageReference section */
1B384A972DC1CFE800F5B1A2 /* 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 */
1B384A982DC1CFE800F5B1A2 /* FacebookCore */ = {
isa = XCSwiftPackageProductDependency;
package = 1B384A972DC1CFE800F5B1A2 /* XCRemoteSwiftPackageReference "facebook-ios-sdk" */;
productName = FacebookCore;
};
1B384A9A2DC1CFE800F5B1A2 /* FacebookLogin */ = {
isa = XCSwiftPackageProductDependency;
package = 1B384A972DC1CFE800F5B1A2 /* XCRemoteSwiftPackageReference "facebook-ios-sdk" */;
productName = FacebookLogin;
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = 1DBC40512DA4EDFC0093FCB0 /* Project object */;
}

View 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
}

View File

@ -6,6 +6,7 @@
//
import UIKit
import FacebookCore
extension AppDelegate {
@ -45,6 +46,12 @@ extension SceneDelegate {
///URLAPP
func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
guard let url = URLContexts.first?.url else {
return
}
ApplicationDelegate.shared.application(UIApplication.shared, open: url, sourceApplication: nil, annotation: [UIApplication.OpenURLOptionsKey.annotation])
}

View File

@ -6,6 +6,7 @@
//
import UIKit
import FacebookCore
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
@ -13,6 +14,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
///Facebook
ApplicationDelegate.shared.application(application, didFinishLaunchingWithOptions: launchOptions)
self.appConfig()
///

View File

@ -0,0 +1,11 @@
//
// SPAPPKey.swift
// MoviaBox
//
// Created by on 2025/4/30.
//
import UIKit
let kSPAppleAppId = "6745007239"
let kSPAppleDownloadPath = "https://apps.apple.com/app/id6670203263"

View File

@ -6,10 +6,55 @@
//
import UIKit
import FacebookLogin
//https://developers.facebook.com/docs/facebook-login/ios?checkpoint_src=any
extension SPLoginManager {
///facebook
func facebookSignLogin(presentingViewController: UIViewController, completer: ((_ model: SPThirdSignModel?) -> 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 = SPThirdSignModel()
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)
}
}
}
}

View File

@ -64,6 +64,12 @@ class SPLoginManager: NSObject {
appleSignLogin { [weak self] model in
self?.requestThirdLogin(thirdSignModel: model, completer: completer)
}
case .faceBook:
facebookSignLogin(presentingViewController: presentingViewController) { [weak self] model in
self?.requestThirdLogin(thirdSignModel: model, completer: completer)
}
default:
break
}

View File

@ -6,5 +6,7 @@
<array>
<string>Default</string>
</array>
<key>keychain-access-groups</key>
<array/>
</dict>
</plist>

View File

@ -2,8 +2,37 @@
<!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>fb1228062532660582</string>
</array>
</dict>
<dict/>
</array>
<key>FacebookAdvertiserIDCollectionEnabled</key>
<true/>
<key>FacebookAppID</key>
<string>1228062532660582</string>
<key>FacebookAutoLogAppEventsEnabled</key>
<true/>
<key>FacebookClientToken</key>
<string>ecc9787c931b242fa912481c41b39bb6</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>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>