[英]Facebook IOS SDK Login works on simulator, not on device
Facebook Login, got myself into a bit of a spot. Facebook Login,让我自己有点位置。
Unfortunately for the job I am doing I only have access to Snow Leopard running xcode 3.2.6 and cannot alter from that. 不幸的是,由于我正在做的工作,我只能访问运行xcode 3.2.6的Snow Leopard,并且不能对此进行更改。 Blast from the past I know.
我知道过去的冲击波。
To get facebook login working using FB SDK 3.0 I used: 为了使用FB SDK 3.0使Facebook登录正常工作,我使用了:
AppDelegate.h: AppDelegate.h:
#import <FacebookSDK/FacebookSDK.h>
....
@property (retain, nonatomic) FBSession *session;
AppDelegate.m: 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: 然后在我的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. 现在,这适用于模拟器4.3。 I think confirming I have the fb App Id set correctly in the plist, the app set up correctly etc.
我认为确认已在plist中正确设置了fb App ID,正确设置了该应用程序等。
However when testing on a device with IOS 6 it crashes with relevant sections of crash log saying: 但是,在使用IOS 6的设备上进行测试时,它会崩溃并显示崩溃日志的相关部分:
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. 现在显然使用xcode 3.2.6,我无法通过xcode运行并访问控制台以在IOS 6设备上进行进一步的调试。 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.
因此,我将该项目发送给了一个朋友(没有付费帐户,因此无法在设备上进行测试),他确认该项目可以在xcode 4.5和模拟器6上运行。
So if it works on the simulator 6 and 4.3 why would it not work on IOS 6 device? 因此,如果它可以在模拟器6和4.3上运行,为什么在IOS 6设备上不能运行呢? 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. 我能找到的唯一解决方案是将雪豹升级到xcode 4.2。 I didn't realise xcode 4.2 was an option for snow leopard.
我没有意识到xcode 4.2是雪豹的选择。 However it is.
但是,确实如此。 The code above worked immediately with no changes in xcode 4.2.
上面的代码可以立即工作,而xcode 4.2中没有任何更改。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.