Facebook Login, got myself into a bit of a spot.
Unfortunately for the job I am doing I only have access to Snow Leopard running xcode 3.2.6 and cannot alter from that. Blast from the past I know.
To get facebook login working using FB SDK 3.0 I used:
AppDelegate.h:
#import <FacebookSDK/FacebookSDK.h>
....
@property (retain, nonatomic) FBSession *session;
AppDelegate.m:
@synthesize session = _session;
...
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation {
return [self.session handleOpenURL:url];
}
Then in my FBLoginViewController.m viewDidLoad:
MyAppDelegate *appDelegate;
appDelegate = [[UIApplication sharedApplication]delegate];
if (!appDelegate.session.isOpen) {
appDelegate.session = [[FBSession alloc] init];
if (appDelegate.session.state == FBSessionStateCreatedTokenLoaded) {
[appDelegate.session openWithCompletionHandler:^(FBSession *session,
FBSessionState status,
NSError *error) {
}];
}
}
Now this worked on the simulator 4.3. I think confirming I have the fb App Id set correctly in the plist, the app set up correctly etc.
However when testing on a device with IOS 6 it crashes with relevant sections of crash log saying:
Exception Type: EXC_CRASH (SIGSYS)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Crashed Thread: 0
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 MyApp 0x000e7cac 0x59000 + 584876
1 libdispatch.dylib 0x34a384b4 0x34a37000 + 5300
2 libdispatch.dylib 0x34a39836 0x34a37000 + 10294
3 MyApp 0x000e7ca0 0x59000 + 584864
4 MyApp 0x000d9d08 0x59000 + 527624
5 MyApp 0x000d9934 0x59000 + 526644
6 MyApp 0x000da6c6 0x59000 + 530118
7 MyApp 0x0005b1f0 0x59000 + 8688
8 MyApp 0x000660a4 0x59000 + 53412
9 UIKit 0x336130a0 0x33525000 + 975008
10 UIKit 0x33613052 0x33525000 + 974930
11 UIKit 0x33613030 0x33525000 + 974896
12 UIKit 0x336128e6 0x33525000 + 973030
13 UIKit 0x33612ddc 0x33525000 + 974300
14 UIKit 0x3353b5ec 0x33525000 + 91628
15 UIKit 0x335287fc 0x33525000 + 14332
16 UIKit 0x33528116 0x33525000 + 12566
17 GraphicsServices 0x382ab5a0 0x382a5000 + 26016
18 GraphicsServices 0x382ab1ce 0x382a5000 + 25038
19 CoreFoundation 0x3331c170 0x33285000 + 618864
20 CoreFoundation 0x3331c112 0x33285000 + 618770
21 CoreFoundation 0x3331af94 0x33285000 + 614292
22 CoreFoundation 0x3328deb8 0x33285000 + 36536
23 CoreFoundation 0x3328dd44 0x33285000 + 36164
24 GraphicsServices 0x382aa2e6 0x382a5000 + 21222
25 UIKit 0x3357c2f4 0x33525000 + 357108
26 MyApp 0x0005b012 0x59000 + 8210
27 MyApp 0x0005afc8 0x59000 + 8136
Thread 0 crashed with ARM Thread State (32-bit):
r0: 0x0000004e r1: 0x00000000 r2: 0x00000000 r3: 0x00000000
r4: 0x3b091bd0 r5: 0x2fda7c0c r6: 0x1cd560e0 r7: 0x2fda6734
r8: 0x00000000 r9: 0x2fda6764 r10: 0x1cd560e0 r11: 0x1cdac4d0
ip: 0x000e7c0d sp: 0x2fda672c lr: 0x34a384b7 pc: 0x000e7cac
cpsr: 0x60000010
What I have tried:
Now obviously with xcode 3.2.6 I cannot run via xcode and access the console for further debugging on my IOS 6 device. So I sent the project to a friend (without paid account so can't test on device) who confirmed it worked on xcode 4.5 and with simulator 6.
So if it works on the simulator 6 and 4.3 why would it not work on IOS 6 device? I am a little stumped....
After playing around (just commenting lines out etc) I think it is crashing at this line:
appdelagate.session = [[FBSession aloc] init];
But am finding it hard to be sure or have any idea why.
Would love some ideas or help, Thanks.
The only solution I could find was to upgrade to xcode 4.2 for snow leopard. I didn't realise xcode 4.2 was an option for snow leopard. However it is. The code above worked immediately with no changes in xcode 4.2.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.