如何解决 Facebook ID 错误

Posted

技术标签:

【中文标题】如何解决 Facebook ID 错误【英文标题】:How to resolve facebook ID errorr 【发布时间】:2016-01-22 02:14:45 【问题描述】:

如何解决此错误,因为我查看了我记得的所有内容,但没有找到答案。

任何帮助将不胜感激。

/**
 * Copyright (c) 2015-present, Parse, LLC.
 * All rights reserved.
 *
 * This source code is licensed under the BSD-style license found in the
 * LICENSE file in the root directory of this source tree. An additional grant
 * of patent rights can be found in the PATENTS file in the same directory.
 */

import UIKit
import Parse

// If you want to use any of the UI components, uncomment this line
// import ParseUI

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate 

    var window: UIWindow?

    //--------------------------------------
    // MARK: - UIApplicationDelegate
    //--------------------------------------

    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()

        // ****************************************************************************
        // Uncomment and fill in with your Parse credentials:
        // Parse.setApplicationId("your_application_id", clientKey: "your_client_key")

        Parse.setApplicationId("xxxxxxxxxx",
            clientKey: "xxxxxxxxxxxxx")

        // iniciar com facebook

        PFFacebookUtils.initializeFacebookWithApplicationLaunchOptions(launchOptions)



        // If you are using Facebook, uncomment and add your FacebookAppID to your bundle's plist as
        // described here: https://developers.facebook.com/docs/getting-started/facebook-sdk-for-ios/
        // Uncomment the line inside ParseStartProject-Bridging-Header and the following line here:
        // PFFacebookUtils.initializeFacebook()
        // ****************************************************************************

        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)
            
        

        //
        //  Swift 1.2
        //
        //        if application.respondsToSelector("registerUserNotificationSettings:") 
        //            let userNotificationTypes = UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound
        //            let settings = UIUserNotificationSettings(forTypes: userNotificationTypes, categories: nil)
        //            application.registerUserNotificationSettings(settings)
        //            application.registerForRemoteNotifications()
        //         else 
        //            let types = UIRemoteNotificationType.Badge | UIRemoteNotificationType.Alert | UIRemoteNotificationType.Sound
        //            application.registerForRemoteNotificationTypes(types)
        //        

        //
        //  Swift 2.0
        //
        //        if #available(iOS 8.0, *) 
        //            let types: UIUserNotificationType = [.Alert, .Badge, .Sound]
        //            let settings = UIUserNotificationSettings(forTypes: types, categories: nil)
        //            application.registerUserNotificationSettings(settings)
        //            application.registerForRemoteNotifications()
        //         else 
        //            let types: UIRemoteNotificationType = [.Alert, .Badge, .Sound]
        //            application.registerForRemoteNotificationTypes(types)
        //        

        return FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
    

    //--------------------------------------
    // MARK: Push Notifications
    //--------------------------------------

    func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) 
        let installation = PFInstallation.currentInstallation()
        installation.setDeviceTokenFromData(deviceToken)
        installation.saveInBackground()

        PFPush.subscribeToChannelInBackground("")  (succeeded: Bool, error: NSError?) in
            if succeeded 
                print("ParseStarterProject successfully subscribed to push notifications on the broadcast channel.\n");
             else 
                print("ParseStarterProject failed to subscribe to push notifications on the broadcast channel with error = %@.\n", error)
            
        
    

    func application(application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: NSError) 
        if error.code == 3010 
            print("Push notifications are not supported in the iOS Simulator.\n")
         else 
            print("application:didFailToRegisterForRemoteNotificationsWithError: %@\n", error)
        
    

    func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject]) 
        PFPush.handlePush(userInfo)
        if application.applicationState == UIApplicationState.Inactive 
            PFAnalytics.trackAppOpenedWithRemoteNotificationPayload(userInfo)
        
    

    ///////////////////////////////////////////////////////////
    // Uncomment this method if you want to use Push Notifications with Background App Refresh
    ///////////////////////////////////////////////////////////
    // func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject], fetchCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void) 
    //     if application.applicationState == UIApplicationState.Inactive 
    //         PFAnalytics.trackAppOpenedWithRemoteNotificationPayload(userInfo)
    //     
    // 

    //--------------------------------------
    // MARK: Facebook SDK Integration
    //--------------------------------------

    ///////////////////////////////////////////////////////////
    // Uncomment this method if you are using Facebook
    ///////////////////////////////////////////////////////////
    // func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject?) -> Bool 
    //     return FBAppCall.handleOpenURL(url, sourceApplication:sourceApplication, session:PFFacebookUtils.session())
    // 


    // resposta do facebook quando ele faz login
    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) 
        FBSDKAppEvents.activateApp()
    



【问题讨论】:

请发布实际的错误消息而不是屏幕截图。 See here 了解详情。谢谢。 【参考方案1】:

例外很明显:

编辑信息 plist 和带有关键 FacebookAppID 的新行,并重视您的 facebook id 或使用 FBSDKSettings.setAppID("your app facebook id")

Where can I find my Facebook application id and secret key?

【讨论】:

以上是关于如何解决 Facebook ID 错误的主要内容,如果未能解决你的问题,请参考以下文章

如何解决“登录错误:登录此应用程序时出错。请稍后重试。” Facebook登录错误

如何解决这个 #606 应用程序在 facebook 广告网络中被阻止错误?

如何解决 cURL 错误 60:Facebook 身份验证时 Laravel 5 中的 SSL 证书

如何解决“Facebook 检测到 MyApp 未使用安全连接传输信息。” Laravel 中的错误

如果 Facebook Messenger 平台上发生 EAI_AGAIN 错误,我该如何解决?

如何解决这个 Facebook SDK 4.0 登录按钮异常