簡體   English   中英

在IOS應用程序中登錄Facebook的對象不能為零

[英]object cannot be nil for Facebook login in IOS app

我試圖將Facebook兼容性整合到我的游戲中,以便能夠在游戲結束時分享你的分數。

我已經按照Facebook的文檔中列出的所有步驟進行了操作,但我似乎無法找到導致此錯誤的原因或設置為nil的對象。

當我按下從以下代碼生成的登錄按鈕時:

FBSDKLoginButton *loginButton = [[FBSDKLoginButton alloc] init];
loginButton.center = self.view.center;
[self.view addSubview:loginButton];

我收到此錯誤:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** setObjectForKey: object cannot be nil (key: client_id)'
*** First throw call stack:
(0x183fc659c 0x1946cc0e4 0x183eb11f8 0x1000b690c 0x1000b6d18 0x1000b6cc4 0x1000b5b8c 0x1000b2794 0x1887a9418 0x18879252c 0x1887a8db4 0x1887a8a40 0x1887a1f94 0x18877568c 0x188a1460c 0x188773bf4 0x183f7e9ec 0x183f7dc90 0x183f7bd40 0x183ea90a4 0x18d04b5a4 0x1887daaa4 0x1000a3f0c 0x194d3aa08)
libc++abi.dylib: terminating with uncaught exception of type NSException

謝謝!

編輯:

0   Eggs                                0x00000001000e1994 -[GameViewController viewDidLoad] + 920
1   UIKit                               0x0000000188775184 <redacted> + 692
2   UIKit                               0x0000000188774e94 <redacted> + 32
3   UIKit                               0x000000018877b55c <redacted> + 72
4   UIKit                               0x0000000188778cdc <redacted> + 260
5   UIKit                               0x00000001887e9d24 <redacted> + 56
6   UIKit                               0x00000001889fd890 <redacted> + 2804
7   UIKit                               0x00000001889ffe08 <redacted> + 1480
8   UIKit                               0x00000001889fe4a0 <redacted> + 184
9   FrontBoardServices                  0x000000018c23562c <redacted> + 28
10  CoreFoundation                      0x0000000183f7ea28 <redacted> + 20
11  CoreFoundation                      0x0000000183f7db30 <redacted> + 312
12  CoreFoundation                      0x0000000183f7c154 <redacted> + 1756
13  CoreFoundation                      0x0000000183ea90a4 CFRunLoopRunSpecific + 396
14  UIKit                               0x00000001887dfaac <redacted> + 552
15  UIKit                               0x00000001887daaa4 UIApplicationMain + 1488
16  Eggs                                0x00000001000e7efc main + 116
17  libdyld.dylib                       0x0000000194d3aa08 <redacted> + 4

我有同樣的問題,但我通過檢查info.plist來解決它。 我建議仔細檢查你的拼寫。 它需要是FacebookAppID,我把它作為FacebookID。 當我修正錯字時,它運行正常。 但是,您可能會遇到不同的問題。

我不認為那3行引起了錯誤。 如果您提供更多的編碼行,那將是很棒的。 請使用以下代碼進行最新的Facebook集成。

   -(void)viewDidLoad{
    FBSDKLoginButton *loginButton = [[FBSDKLoginButton alloc] init];
    [self.view addSubview:loginButton];

    self.loginButton.readPermissions = @[@"public_profile", @"email", @"user_friends"];
    self.loginButton.delegate = self;
    [FBSDKProfile enableUpdatesOnAccessTokenChange:YES];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(profileUpdated:) name:FBSDKProfileDidChangeNotification object:nil];

     }
-(void)profileUpdated:(NSNotification *) notification{
    NSLog(@"User name: %@",[FBSDKProfile currentProfile].name);
    NSLog(@"User ID: %@",[FBSDKProfile currentProfile].userID);
}

- (void)  loginButton:(FBSDKLoginButton *)loginButton
didCompleteWithResult:(FBSDKLoginManagerLoginResult *)result
                error:(NSError *)error{

}
- (void)loginButtonDidLogOut:(FBSDKLoginButton *)loginButton{

}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM