1
當我在我的應用程序中調用以下Objective C代碼時,出現異常。錯誤您必須初始化PFFVideosUtils
[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];
}
}];
終止應用程序由於未捕獲的異常「NSInternalInconsistencyException」,理由是:「你必須要在通話初始化PFFacebookUtils + initializeFacebookWithApplicationLaunchOptions」
下面是寫在斯威夫特和我的AppDelegate代碼我不太清楚如何初始化它在Swift錯誤中所說的內容嗎?我正在使用最新版本的Parse,並且在我的PodFile中,我有以下「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
}
謝謝伊凡,我曾嘗試過,但隨後刪除了該行代碼,因爲它不承認PFFVideosUtils,因爲愚蠢的我忘了導入ParseFacebookUtilsV4 – SamoanProgrammer
歡迎您:) –