我仍然在我的項目中使用Objective-C,因爲它是一個傳統項目。我之前使用過Parse,現在我正在嘗試添加FB集成。我設法讓一切都編譯 - 這些都是我通過CocoaPods安裝的。ParseFacebookUtilsV4 ::使用Parse/FB SDK在iOS中初始化FacebookWithApplicationLaunchOptions問題
Using Bolts (1.2.0)
Installing FBSDKCoreKit (4.3.0)
Installing FBSDKLoginKit (4.3.0)
Using Parse (1.7.5)
Installing ParseFacebookUtilsV4 (1.7.5)
這是我的代碼。
FirstViewController
-(void) viewDidAppear:(BOOL)animated
{
// Do any additional setup after loading the view, typically from a nib.
if (![PFUser currentUser] || // Check if user is cached
![PFFacebookUtils isLinkedWithUser:[PFUser currentUser]]) { // Check if user is linked to Facebook
PFLogInViewController *logInController = [[PFLogInViewController alloc] init];
logInController.fields = (PFLogInFieldsUsernameAndPassword
| PFLogInFieldsFacebook
| PFLogInFieldsDismissButton);
[self presentViewController:logInController animated:YES completion:nil];
[self presentViewController:loginViewController animated:YES completion:NULL];
} else {
NSLog(@"User is cached and showing content.");
}
}
當視圖中顯示了,我點擊登錄與Facebook,我有這樣的錯誤。
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'You must initialize PFFacebookUtils with a call to +initializeFacebookWithApplicationLaunchOptions'
如果我添加這對我的AppDelegate, [PFFacebookUtils initializeFacebookWithApplicationLaunchOptions:launchOptions];
我得到一個編譯的問題 - 沒有已知的類。
基於this,我應該在PFFVideosUtils中添加一個臨時攻擊,但是該方法中不存在方法initializeFacebookWithApplicationLaunchOptions
。
我也嘗試在我的AppDelegate中添加這個。
[PFFacebookUtils initializeFacebook];
在這種情況下,錯誤的是:
+[PFFacebookUtils initializeFacebook]: unrecognized selector sent to class 0x10024f420
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[PFFacebookUtils initializeFacebook]: unrecognized selector sent to class 0x10024f420'
任何想法/解決方案?
您是否正確設置了您的.plist中的Facebook App ID?您可以查看[入門文檔](https://developers.facebook.com/docs/ios/getting-started)。 – amudi