![](/img/trans.png)
[英]Iphone5 / ios6.1.3 and Facebook SDK 3.2.1 on iOS - com.facebook.sdk Error 2 on device
[英]Facebook SDK 3.6 for iOS error 2 on device
Facebook登錄可以在iOS模擬器上正常運行,但不能在設備(iPhone 4)上運行。 至於它在模擬器上的工作,我認為facebookId,權限....設置都可以。
NSArray *permissions = [NSArray arrayWithObjects:@"email",nil];
[FBSession openActiveSessionWithReadPermissions:permissions allowLoginUI:YES completionHandler:^(FBSession *session, FBSessionState status, NSError *error) {
[self sessionStateChanged:session state:status error:error];
}];
有什么幫助嗎? 謝謝
解決了!!!
我在FacebookSDK中檢查了SessionLoginSample,並找到了解決方案。
我不得不將上面的代碼更改為此:
MyAppDelegate *appDelegate = [[UIApplication sharedApplication]delegate];
if (!appDelegate.session.isOpen || appDelegate.session.state != FBSessionStateCreated) {
// Create a new, logged out session.
appDelegate.session = [[FBSession alloc] init];
}
// if the session isn't open, let's open it now and present the login UX to the user
[appDelegate.session openWithCompletionHandler:^(FBSession *session,
FBSessionState status,
NSError *error) {
// and here we make sure to update our UX according to the new session state
[self sessionStateChanged:session state:status error:error];
}];
我在MyAppDelegate.h中添加了一個屬性
@property (strong, nonatomic) FBSession *session;
並更改MyAppDelegate.m中的方法
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication: (NSString *)sourceApplication annotation:(id)annotation
{
// return [FBSession.activeSession handleOpenURL:url];
return [FBAppCall handleOpenURL:url sourceApplication:sourceApplication withSession:self.session];
}
現在工作正常:)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.