gpt4 book ai didi

ios - Facebook SDK 错误与 Branch(深层链接)相结合 - iOS

转载 作者:行者123 更新时间:2023-11-30 11:59:29 27 4
gpt4 key购买 nike

如果我使用 Branch 框架,Facebook SDK 会出现问题。

在我的应用程序中,我向新用户发送了一个深层链接,这工作得很好,但现在我的 Facebook 登录被破坏了。我已经尝试了一些方法,但只有当我删除应用程序并再次安装时它才有效。然后我可以登录 Facebook,但如果我注销并尝试再次登录,它就会停止工作。

这是我的 AppDelegate:

import Foundation
import UIKit
import FacebookCore
import HealthKit
import Branch


@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {


var window: UIWindow?
let healthkitManager = HealthkitManager()
var startedChallenge: StartedChallenge!

// latest
let sessionParams = Branch.getInstance().getLatestReferringParams()

// first
let installParams = Branch.getInstance().getFirstReferringParams()

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

// Navigation appearence
let navigationBarAppearace = UINavigationBar.appearance()

// Make navigation bar translucent
navigationBarAppearace.setBackgroundImage(UIImage(), for: .default)
navigationBarAppearace.shadowImage = UIImage()
navigationBarAppearace.isTranslucent = true

// Make navigation bar text darkGray
navigationBarAppearace.titleTextAttributes = [NSForegroundColorAttributeName:UIColor.darkGray]
navigationBarAppearace.tintColor = UIColor.white

// White status bar
UIApplication.shared.statusBarStyle = .lightContent

healthkitManager.authorize(forReadingQuantities: [.bodyMass, .height], forReadingCharacteristics: [.biologicalSex,.dateOfBirth])

self.window = UIWindow(frame: UIScreen.main.bounds)

self.window = UIWindow(frame: UIScreen.main.bounds)

self.window = UIWindow(frame: UIScreen.main.bounds)

let storyboard = UIStoryboard(name: "LaunchScreen", bundle: nil)
let vc = storyboard.instantiateViewController(withIdentifier: "SplashVC")
self.window?.rootViewController = vc;
self.window?.makeKeyAndVisible()

// ----------------------------------------------------------- Deep linking ------------------------------------------------------------------------------------------------------ //

// listener (within AppDelegate didFinishLaunchingWithOptions)
let branch: Branch = Branch.getInstance()

// within AppDelegate application.didFinishLaunchingWithOptions
branch.initSession(launchOptions: launchOptions, andRegisterDeepLinkHandler: { params , error in
if let params = params, error == nil && params["~channel"] != nil {
// params are the deep linked params associated with the link that the user clicked -> was re-directed to this app
print("params: %@", params.description as Any)
// load the view to show the viewcontroller
let startedChallenge = StartedChallenge()
startedChallenge.title = params[StartedChallenge.titleKey] as! String
startedChallenge.category = params[StartedChallenge.categoryKey] as! String
startedChallenge.days = Int(params[StartedChallenge.daysKey] as! String)!

if let frequency = params[StartedChallenge.frequencyKey] as? String {
startedChallenge.frequency = Int(frequency)!
}

let storyboard : UIStoryboard = UIStoryboard(name: "Welcome", bundle: nil)
let innerPageVC: InnerPageViewController = storyboard.instantiateViewController(withIdentifier: "InnerPageViewController") as! InnerPageViewController
innerPageVC.startedChallenge = startedChallenge
self.window = UIWindow(frame: UIScreen.main.bounds)
self.window?.rootViewController = innerPageVC
self.window?.makeKeyAndVisible()

} else {
print("ADMIN: %@", params?.description as Any)
var vcName = "Login"
if UserManager.getToken() != nil {
vcName = "Welcome"
let storyboard = UIStoryboard(name: "Welcome", bundle: nil)
let vc = storyboard.instantiateViewController(withIdentifier: vcName)
self.window?.rootViewController = vc;
self.window?.makeKeyAndVisible()
} else {
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let vc = storyboard.instantiateViewController(withIdentifier: vcName)
self.window?.rootViewController = vc;
self.window?.makeKeyAndVisible()

}
}
})

SDKApplicationDelegate.shared.application(application, didFinishLaunchingWithOptions: launchOptions)
// always return true

return true
}

如果我禁用 Branch,我的 Facebook 登录就可以正常工作,我找不到问题。

也许有人可以帮助我:)

最佳答案

检查您的以下回调方法。 Branch 和 Facebook SDK 使用相同的方法。调用方法是否有意外变化。另外,验证 Facebook 使用的 URL 架构的任何更改

func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
return FBSDKApplicationDelegate.sharedInstance().application(application, open: url, sourceApplication: sourceApplication, annotation: annotation)
}

关于ios - Facebook SDK 错误与 Branch(深层链接)相结合 - iOS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47431558/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com