gpt4 book ai didi

ios - 如何在 swift 上设置 facebook SDK?

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

我正在一个 swift 应用程序中设置 facebook sdk。有一部分我需要连接到 delagate,facebook 提供了以下代码:

//  AppDelegate.m
#import <FBSDKCoreKit/FBSDKCoreKit.h>

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[[FBSDKApplicationDelegate sharedInstance] application:application
didFinishLaunchingWithOptions:launchOptions];
return YES;
}

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
return [[FBSDKApplicationDelegate sharedInstance] application:application
openURL:url
sourceApplication:sourceApplication
annotation:annotation
];
}

这是 obj-c。这个的 swift 版本是什么?

最佳答案

只需在您的 AppDelegate.swift 文件中添加这些方法即可初始化 FacebookSDK。

func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool {
return FBSDKApplicationDelegate.sharedInstance().application(application, openURL: url, sourceApplication: sourceApplication, annotation: annotation)
}

func applicationDidBecomeActive(application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
FBSDKAppEvents.activateApp()
}

关于ios - 如何在 swift 上设置 facebook SDK?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34802795/

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