簡體   English   中英

FBSession.m在Facebook6.0中使用FacebookSdk.framework崩潰

[英]FBSession.m Crashes in iOS6.0 with FacebookSdk.framework

我正在使用新的FacebookSdk,並且在iOS 6.0中運行時我的應用程序崩潰了。這是崩潰日志

*** Assertion failure in -[FBSession close], /Users/jacl/src/release/ios-sdk/src/FBSession.m:404
2012-12-12 12:48:49.993 localfave[1406:1d903] uncaughtExceptionHnadler -- Exception FBSession: should only be used from a single thread
2012-12-12 12:48:49.996 test[1406:1d903] Stack trace: (
    0   CoreFoundation                      0x02d6b02e __exceptionPreprocess + 206
    1   libobjc.A.dylib                     0x01cd6e7e objc_exception_throw + 44
    2   CoreFoundation                      0x02d6ae78 +[NSException raise:format:arguments:] + 136
    3   Foundation                          0x0176cf35 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 116
    4   localfave                           0x000f6e1d -[FBSession close] + 177
    5   localfave                           0x000f753e +[FBSession setActiveSession:] + 50
    6   localfave                           0x000fa6ee +[FBSession openActiveSessionWithPermissions:allowLoginUI:allowSystemAccount:isRead:defaultAudience:completionHandler:] + 230
    7   test                           0x000f7408 +[FBSession openActiveSessionWithReadPermissions:allowLoginUI:completionHandler:] + 82
    8   test                           0x00002fc6 -[AppDelegate openSessionWithAllowLoginUI:] + 166
    9   test                           0x0008adc5 -[FacebookLoginViewController registerFacebook:] + 165
    10  libobjc.A.dylib                     0x01cea705 -[NSObject performSelector:withObject:withObject:] + 77
    11  UIKit                               0x00c21920 -[UIApplication sendAction:to:from:forEvent:] + 96
    12  UIKit                               0x00c218b8 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
    13  UIKit                               0x00ce2671 -[UIControl sendAction:to:forEvent:] + 66
    14  UIKit                               0x00ce2bcf -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 578
    15  UIKit                               0x00ce1d38 -[UIControl touchesEnded:withEvent:] + 546
    16  UIKit                               0x00c5133f -[UIWindow _sendTouchesForEvent:] + 846
    17  UIKit                               0x00c51552 -[UIWindow sendEvent:] + 273
    18  UIKit                               0x00c2f3aa -[UIApplication sendEvent:] + 436
    19  UIKit                               0x00c20cf8 _UIApplicationHandleEvent + 9874
    20  GraphicsServices                    0x03057df9 _PurpleEventCallback + 339
    21  GraphicsServices                    0x03057ad0 PurpleEventCallback + 46
    22  CoreFoundation                      0x02ce0bf5 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
    23  CoreFoundation                      0x02ce0962 __CFRunLoopDoSource1 + 146
    24  CoreFoundation                      0x02d11bb6 __CFRunLoopRun + 2118
    25  CoreFoundation                      0x02d10f44 CFRunLoopRunSpecific + 276
    26  CoreFoundation                      0x02d10e1b CFRunLoopRunInMode + 123
    27  GraphicsServices                    0x030567e3 GSEventRunModal + 88
    28  GraphicsServices                    0x03056668 GSEventRun + 104
    29  UIKit                               0x00c1e65c UIApplicationMain + 1211
    30  test                           0x00002545 main + 213
    31  test                           0x00002425 start + 53
)

代碼是

/*
 * Opens a Facebook session and optionally shows the login UX.
 */
- (BOOL)openSessionWithAllowLoginUI:(BOOL)allowLoginUI {
    return [FBSession openActiveSessionWithReadPermissions:nil
                                              allowLoginUI:allowLoginUI
                                         completionHandler:^(FBSession *session,
                                                             FBSessionState state,
                                                             NSError *error) {
                                             [self sessionStateChanged:session
                                                                 state:state
                                                                 error:error];
                                         }];
}

/*
 * Callback for session changes.
 */

請幫忙!

只需在要發布到Facebook上的地方編寫此代碼,並丟棄您為進行Facebook集成所做的所有功能,我想您已經在.h文件中導入了#import。

if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook])
    {
        SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];

        SLComposeViewControllerCompletionHandler myBlock = ^(SLComposeViewControllerResult result){
            if (result == SLComposeViewControllerResultCancelled) {
                NSLog(@"ResultCancelled");
            } else

            {
                NSLog(@"Success");
            }

            [controller dismissViewControllerAnimated:YES completion:Nil];
        };
        controller.completionHandler =myBlock;
        [controller setInitialText:@"Awesome App"];
        [controller addImage:photoImage.image];
        [self presentViewController:controller animated:YES completion:Nil];
    }

讓我知道它是否有效.... !!!

編碼愉快!!!

確保您具有社交,帳戶,AdSupport框架,並且它們是可選的。 復制FacebookSDK.framework,FacebookSDKResources.bundle,FBUserSettingsViewResources.bundle。 可以在iOS版Facebook開發人員網頁上找到它們。 如果問題再次出現,請嘗試刪除所有框架,然后再次添加它們。 這是框架問題,而不是代碼問題。

暫無
暫無

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

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