按照教程中的指示调用FBSession.activeSession会导致NSException

时间:2013-02-11 07:15:14

标签: iphone ios facebook exception

我正在尝试在我的iphone应用中启用Facebook登录。

我按照此页面上的说明操作: https://developers.facebook.com/docs/howtos/login-with-facebook-using-ios-sdk/#step4

我已按照步骤#4(登录Facebook)中的说明操作,但运行时我的代码崩溃了。

这是造成崩溃的方法:

- (void)applicationDidBecomeActive:(UIApplication *)application
{
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.

    // We need to properly handle activation of the application with regards to Facebook Login
    // (e.g., returning from iOS 6.0 Login Dialog or from fast app switching).
    NSLog(@"here 1");
    NSLog(@"active session: %@",FBSession.activeSession);
    [FBSession.activeSession handleDidBecomeActive];
    NSLog(@"here 2");
}

这是崩溃发生时的堆栈跟踪(应用程序名称替换为XXX):

2013-02-11 17:31:17.956 TRIO[9426:907] here 1
* thread #1: tid = 0x2503, 0x324d9960 libobjc.A.dylib`objc_exception_throw, stop reason = breakpoint 1.1
frame #0: 0x324d9960 libobjc.A.dylib`objc_exception_throw
frame #1: 0x3161af98 CoreFoundation`-[NSException raise] + 8
frame #2: 0x0009f7cc XXX`-[FBSession initWithAppID:permissions:defaultAudience:urlSchemeSuffix:tokenCacheStrategy:] + 240 at FBSession.m:236
frame #3: 0x0009f6d6 XXX`-[FBSession initWithAppID:permissions:urlSchemeSuffix:tokenCacheStrategy:] + 46 at FBSession.m:208
frame #4: 0x0009f680 XXX`-[FBSession init] + 32 at FBSession.m:191
frame #5: 0x000a061a XXX`+[FBSession activeSession] + 62 at FBSession.m:568
frame #6: 0x00073c4e XXX`-[AppDelegate applicationDidBecomeActive:] + 66 at AppDelegate.m:118
frame #7: 0x38e3bae2 UIKit`-[UIApplication _stopDeactivatingForReason:] + 342
frame #8: 0x38e219b8 UIKit`-[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 1072
frame #9: 0x38dc9c38 UIKit`-[UIApplication handleEvent:withNewEvent:] + 1004
frame #10: 0x38dc96cc UIKit`-[UIApplication sendEvent:] + 72
frame #11: 0x38dc911a UIKit`_UIApplicationHandleEvent + 6154
frame #12: 0x393605a2 GraphicsServices`_PurpleEventCallback + 590
frame #13: 0x393601d2 GraphicsServices`PurpleEventCallback + 34
frame #14: 0x315f0172 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 34
frame #15: 0x315f0116 CoreFoundation`__CFRunLoopDoSource1 + 138
frame #16: 0x315eef98 CoreFoundation`__CFRunLoopRun + 1384
frame #17: 0x31561ebc CoreFoundation`CFRunLoopRunSpecific + 356
frame #18: 0x31561d48 CoreFoundation`CFRunLoopRunInMode + 104
frame #19: 0x38e2047c UIKit`-[UIApplication _run] + 668
frame #20: 0x38e1d2f8 UIKit`UIApplicationMain + 1120
frame #21: 0x00073748 XXX`main + 96 at main.m:16

当我运行Facebook示例代码时,它们工作正常,我相信我已经添加了所有必需的框架。

感谢。

1 个答案:

答案 0 :(得分:4)

我遇到了与上面相同的错误,因为我没有将自己的FacebookAppID和“URL类型”键添加到我的项目的info.plist中