ios – Facebook登录集成到Parse.com App

我正在尝试在我的应用程序中实现Facebook登录选项.我按照Parse网站和Facebook开发者页面上的所有说明进行操作.我添加了框架,修改了plist文件添加了正确的代码,但是当我启动App时,我得到了这个异常:
2015-07-14 17:50:08.939 ########[35815:2144465] -[ParseManager coreManager]: unrecognized selector sent to instance 0x7f9cdadad720
2015-07-14 17:50:08.953 ########[35815:2144465] *** Terminating app due to uncaught exception 'NSinvalidargumentexception',reason: '-[ParseManager coreManager]: unrecognized selector sent to instance 0x7f9cdadad720'
*** First throw call stack:
(
0   CoreFoundation                      0x000000010a3cdc65 __exceptionPreprocess + 165
1   libobjc.A.dylib                     0x000000010a066bb7 objc_exception_throw + 45
2   CoreFoundation                      0x000000010a3d50ad -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3   CoreFoundation                      0x000000010a32b13c ___forwarding___ + 988
4   CoreFoundation                      0x000000010a32acd8 _CF_forwarding_prep_0 + 120
5   ########                          0x0000000105c822f0 +[PFFacebookUtils initializefacebookWithApplicationLaunchOptions:] + 151
6   ########                          0x0000000105954c6c -[SMAppDelegate application:didFinishLaunchingWithOptions:] + 1132
7   UIKit                               0x00000001088ef748 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 240
8   UIKit                               0x00000001088f0357 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 2540
9   UIKit                               0x00000001088f319e -[UIApplication _runWithMainScene:transitionContext:completion:] + 1349
10  UIKit                               0x00000001088f2095 -[UIApplication workspaceDidEndTransaction:] + 179
11  FrontBoardServices                  0x000000010be2b5e5 __31-[FBSSerialQueue performAsync:]_block_invoke_2 + 21
12  CoreFoundation                      0x000000010a30141c __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
13  CoreFoundation                      0x000000010a2f7165 __CFRunLoopdoblocks + 341
14  CoreFoundation                      0x000000010a2f6f25 __CFRunLoopRun + 2389
15  CoreFoundation                      0x000000010a2f6366 CFRunLoopRunSpecific + 470
16  UIKit                               0x00000001088f1b02 -[UIApplication _run] + 413
17  UIKit                               0x00000001088f48c0 UIApplicationMain + 1282
18  ########                          0x00000001059c4a9f main + 111
19  libdyld.dylib                       0x000000010a918145 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

这些是我在项目中实际拥有的框架和库:

奇怪的是,如果我从零创建一个新项目,我根本没有问题,登录工作正常.

编辑:我仍在尝试解决这个问题.通过从[PFFacebookUtils initializefacebookWithApplicationLaunchOptions:launchOptions]更改PFFacebookUtils初始化代码,我设法启动了App而没有错误;到[PFFacebookUtils初始化];但是如果我尝试使用代码[PFFacebookUtils logInInBackgroundWithReadPermissions:nil block:^(PFUser * user,NSError * error){}登录按钮,则会出现另一个异常因未捕获的异常’NSInternalInconsistencyException’而终止app,原因:’你必须通过调用initializefacebookWithApplicationLaunchOptions来初始化PFFacebookUtils

我正按照建议添加我正在使用的代码

在我的AppDelegate.m中

#import <FBSDKCoreKit/FBSDKCoreKit.h>
#import <ParseFacebookUtilsV4/PFFacebookUtils.h>

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{

// PARSE
[Parse setApplicationId: SMParseApplicationId
              clientKey: SMParseClientId];

// FACEBOOK
[PFFacebookUtils initializefacebookWithApplicationLaunchOptions:launchOptions];


[PFAnalytics trackAppOpenedWithLaunchOptions:launchOptions];
//*****

// GOOGLE MAP API
[GMSServices provideAPIKey: SMGoolgeMapApiKey];
//*****

return [[FBSDKApplicationDelegate sharedInstance] application:application
                                didFinishLaunchingWithOptions:launchOptions];
}

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(Nsstring *)sourceApplication annotation:(id)annotation {
return [[FBSDKApplicationDelegate sharedInstance] application:application
                                                      openURL:url
                                            sourceApplication:sourceApplication
                                                   annotation:annotation];
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
  [FBSDKAppEvents activateApp];
}

解决方法

我经历了同样的斗争,尝试了许多不同的方法来设置Parse与Facebook登录.我不得不说,我没有使用Obj-C的经验,但这是我工作的Swift Parse w / Facebook登录应用程序,我希望能给你一些见解.

在我的AppDelegate.swift中:

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

    Parse.setApplicationId("ID",clientKey:"KEY")
    PFFacebookUtils.initializefacebookWithApplicationLaunchOptions(launchOptions)
    FBSDKProfile.enableupdatesOnAccesstokenChange(true)


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


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

在我的LoginViewController.swift中:

//My custom storyboard button
    @IBAction func fbLogin(sender: AnyObject) {

    var permissions = ["public_profile","email"]
    PFFacebookUtils.logInInBackgroundWithReadPermissions(permissions) {
        (user: PFUser?,error: NSError?) -> Void in
        if let user = user {
            if user.isNew {
                println("User signed up and logged in through Facebook!")
                self.facebookSignUp(user)
            } else {
                println("User logged in through Facebook!")
                self.performSegueWithIdentifier("LoginSuccessful",sender: self)
            }
        } else {
            println("Uh oh. The user cancelled the Facebook login.")
        }
    }
}



override func viewDidLoad() {
    super.viewDidLoad()

    if PFUser.currentUser() != nil {
        movetoNextView() //Segue to next ViewController
    }
}


func facebookSignUp(user: PFUser) -> Void{
    var request = FBSDKGraphRequest(graPHPath: "me",parameters: nil)
    var userID:String

    request.startWithCompletionHandler { (connection: FBSDKGraphRequestConnection!,result: AnyObject!,error: NSError!) -> Void in
        if error == nil {
            user["fullName"] = result["name"]
            var facebookUserID = result["id"] as! String
            user["facebookUserID"] = facebookUserID

            user.save()
            self.performSegueWithIdentifier("LoginSuccessful",sender: self)

        } else {
            println(error)
            PFUser.logout()
        }

    }

}

相关文章

当我们远离最新的 iOS 16 更新版本时,我们听到了困扰 Apple...
欧版/美版 特别说一下,美版选错了 可能会永久丧失4G,不过只...
一般在接外包的时候, 通常第三方需要安装你的app进行测...
前言为了让更多的人永远记住12月13日,各大厂都在这一天将应...