Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

iphone - Facebook-Ios-Sdk 3.0.8 Crash Xcode on Alternative Login

I am using Facebook-ios-sdk 3.0.8 to login in my app. it works fines on the first time and gives me the Username from the FbGraph but It crashes the Xcode in my next login.. what would be reason...please check code and let me know...

- (IBAction)buttonClickHandler:(id)sender {
// get the app delegate so that we can access the session property
AppDelegate *appDelegate = [[UIApplication sharedApplication]delegate];

// this button's job is to flip-flop the session from open to closed
if (appDelegate.session.isOpen) {

    [appDelegate.session closeAndClearTokenInformation];

} else {
    if (appDelegate.session.state != FBSessionStateCreated) {

        appDelegate.session = [[FBSession alloc] init];
    }


    [FBSession.activeSession openWithBehavior:FBSessionLoginBehaviorForcingWebView

                        completionHandler:^(FBSession *session,

                                            FBSessionState state,

                                            NSError *error) {
                            // and here we make sure to update our UX according to the new session state
                            [self updateView];
                            NSLog(@" state=%d",state);

                            [FBRequestConnection
                             startForMeWithCompletionHandler:^(FBRequestConnection *connection,
                                                               id<FBGraphUser> user,
                                                               NSError *error) {

                                 userInfo = @"";

                                 // Example: typed access (name)
                                 // - no special permissions required
                                 userInfo = user.username;

                                 NSLog(@"string %@", userInfo); 


                             }];




                        }];    } 


}

first login Output

2013-01-16 13:56:35.613 facebooktest[2690:f803]  state=513
2013-01-16 13:56:36.335 facebooktest[2690:f803] string christien.101012

below output on next login

 2013-01-16 13:56:42.747 facebooktest[2690:f803] *** Terminating app due to uncaught exception 'com.facebook.sdk:InvalidOperationException', reason: 'FBSession: an attempt was made to open an already opened or closed session'
*** First throw call stack:
(0x15ca052 0x175bd0a 0x15c9f11 0x1249f 0x3043 0x15cbec9 0x11b5c2 0x11b55a 0x1c0b76 0x1c103f 0x1c02fe 0x140a30 0x140c56 0x127384 0x11aaa9 0x14b4fa9 0x159e1c5 0x1503022 0x150190a 0x1500db4 0x1500ccb 0x14b3879 0x14b393e 0x118a9b 0x1e38 0x1d95 0x1)

and ** what would be the difference between **

[FBSession.activeSession openWithBehavior:FBSessionLoginBehaviorForcingWebView

                        completionHandler:^(FBSession *session,

                                            FBSessionState state,

                                            NSError *error)

and

 [appDelegate.session openWithBehavior:FBSessionLoginBehaviorForcingWebView

                        completionHandler:^(FBSession *session,

                                            FBSessionState state,

                                            NSError *error) 

in simple words appDelegate.session and FBSession.activeSession because if i use appDelegate.session instead of that it does not gives me the user.username and not crash ...and i use FBSession.activeSession it gives me the user.username for the first time then on next time it crashes..

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...