gpt4 book ai didi

ios - 错误您必须初始化 PFFacebookUtils

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

当我在我的应用程序中调用以下 Objective C 代码时,出现异常。

    [PFFacebookUtils logInInBackgroundWithReadPermissions:permissions block:^(PFUser *user, NSError *error) {
if (!user) {
NSLog(@"Uh oh. The user cancelled the Facebook login.");
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Login Failed"
message:@"The user cancelled the Facebook login."
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
} else if (user.isNew) {
NSLog(@"User signed up and logged in through Facebook!");
[self performSegueWithIdentifier:@"logInSegue" sender:sender];
} else {
NSLog(@"User logged in through Facebook!");
[self performSegueWithIdentifier:@"logInSegue" sender:sender];
}
}];

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'You must initialize PFFacebookUtils with a call to +initializeFacebookWithApplicationLaunchOptions'

下面是 AppDelegate 中用 Swift 编写的代码,我不太确定如何初始化它在 Swift 错误中所说的内容?我正在使用最新版本的 Parse,也在我的 PodFile 中,我有以下 pod 'ParseFacebookUtilsV4'?有什么想法,请问如何解决这个问题?

    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]?) -> Bool {

// Enable storing and querying data from Local Datastore.
// Remove this line if you don't want to use Local Datastore features or want to use cachePolicy.
Parse.enableLocalDatastore()

Parse.setApplicationId(appID, clientKey: clientKey)
PFAnalytics.trackAppOpenedWithLaunchOptions(launchOptions)

let granted: Bool = AppDelegate.IsNotificationPermissionGranted()
if (granted) {
AppDelegate.registerNotification()
}

//code block from starter project
PFUser.enableAutomaticUser()

let defaultACL = PFACL();
// If you would like all objects to be private by default, remove this line.
//defaultACL.setPublicReadAccess(true)

PFACL.setDefaultACL(defaultACL, withAccessForCurrentUser:true)

if application.applicationState != UIApplicationState.Background {
// Track an app open here if we launch with a push, unless
// "content_available" was used to trigger a background push (introduced in iOS 7).
// In that case, we skip tracking here to avoid double counting the app-open.

let preBackgroundPush = !application.respondsToSelector("backgroundRefreshStatus")
let oldPushHandlerOnly = !self.respondsToSelector("application:didReceiveRemoteNotification:fetchCompletionHandler:")
var noPushPayload = false;
if let options = launchOptions {
noPushPayload = options[UIApplicationLaunchOptionsRemoteNotificationKey] != nil;
}
if (preBackgroundPush || oldPushHandlerOnly || noPushPayload) {
PFAnalytics.trackAppOpenedWithLaunchOptions(launchOptions)
}
}

return true
}

最佳答案

在 AppDelegate 类的 didFinishLaunchingWithOptions 方法中添加如下代码

PFFacebookUtils.initializeFacebookWithApplicationLaunchOptions(launchOptions)

请注意,您可能需要先导入 ParseFacebookUtilsV4。

关于ios - 错误您必须初始化 PFFacebookUtils,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35366379/

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