2015-07-14 16 views
6

Tôi đang cố triển khai tùy chọn đăng nhập Facebook trong Ứng dụng của mình. Tôi đã làm theo tất cả các hướng dẫn trên trang web Parse và trên trang dành cho nhà phát triển Facebook. Tôi được thêm vào các khuôn khổ, sửa đổi các tập tin plist và thêm mã đúng nhưng khi tôi khởi động App tôi nhận được ngoại lệ này:Tích hợp đăng nhập Facebook vào Parse.com 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 

Đây là những Khung và các thư viện Tôi thực sự có trên dự án của tôi: enter image description here

Điều kỳ lạ là nếu tôi tạo một dự án mới từ số không, tôi không có vấn đề gì cả và đăng nhập hoạt động chính xác.

Chỉnh sửa: Tôi vẫn đang cố giải quyết vấn đề này. Tôi quản lý để khởi động các ứng dụng mà không có lỗi bằng cách thay đổi mã PFFacebookUtils khởi [PFFacebookUtils initializeFacebookWithApplicationLaunchOptions:launchOptions];-[PFFacebookUtils initialize]; nhưng sau đó nếu tôi cố gắng đăng nhập thông qua một nút với mã [PFFacebookUtils logInInBackgroundWithReadPermissions:nil block:^(PFUser *user, NSError *error) {} ngoại lệ khác xuất hiện Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'You must initialize PFFacebookUtils with a call to +initializeFacebookWithApplicationLaunchOptions'

tôi thêm mã Tôi đang sử dụng như đề xuất:

trong tôi 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]; 
} 
+0

Bạn đã thêm FacebookAppID và FacebookDisplayName của bạn cũng như các loại URL ** đúng ** trong plist của bạn? –

+0

Vâng tôi đã làm. Tôi đã làm nhiều hơn một lần để chắc chắn rằng tất cả đều ổn. – Diego

+0

Tôi đề nghị bạn đăng tất cả các mã có liên quan để đăng nhập Fb để chúng tôi có thể thấy những gì không chính xác hoặc bị thiếu. – SanitLee

Trả lời

5

Hiện đã có một lỗi trong Parse SDK, here là báo cáo lỗi với các câu trả lời sau đây để sửa chữa nó.

1) Tới PFFacebookUtils.h

2) thay đổi:

(void)initializeFacebookWithApplicationLaunchOptions:(NSDictionary *)launchOptions; 

tới:

(void)initializeFacebookWithApplicationLaunchOptions:(PF_NULLABLE NSDictionary *)launchOptions; 

Tuy nhiên, màu Tây Nguyên đã phát hành một phiên bản mới hơn của SDK của họ (v1.7.2), sẽ giải quyết vấn đề. Vui lòng kiểm tra xem bạn đang sử dụng SDK nào.

+0

Tôi đã nhận thức được rằng lỗi, trên thực tế phiên bản SDK Parse tôi đang sử dụng nó là chính xác và không có dòng bên phải trong tập tin PFFacebookUtils.h. – Diego

6

Tôi đã trải qua cuộc đấu tranh tương tự này và đã thử nhiều cách khác nhau để thiết lập Parse bằng Đăng nhập Facebook. Mặc dù vậy, tôi phải nói rằng, tôi không có kinh nghiệm với Obj-C, nhưng đây là ứng dụng Swift Parse w/Facebook Login đang hoạt động mà tôi hy vọng có thể cung cấp cho bạn một số thông tin chi tiết.

Trong AppDelegate.swift tôi:

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

Trong tôi 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() 
     } 

    } 

} 
Các vấn đề liên quan