我正在尝试将Facebook登录集成到我的应用程序中,并且过去两天一直没有运气。
登录按钮有效:它将我登录,然后将文本更改为“注销”。
然而,没有别的办法。我无法得到这个名字,我尝试在我的代码中放置随机NSLog
语句,但唯一打印的是viewDidLoad
中的语句。没别了。
这是我的代码(我正在使用btw按钮的图形实现)
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
NSLog(@"Print 1");
// Call FBAppCall's handleOpenURL:sourceApplication to handle Facebook app responses
BOOL wasHandled = [FBAppCall handleOpenURL:url sourceApplication:sourceApplication];
// You can add your app-specific url handling code here if needed
return wasHandled;
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSLog(@"Print 2");
// Override point for customization after application launch.
[FBLoginView class];
self.loginView.readPermissions = @[@"basic_info", @"email", @"user_likes"];
NSLog(@"Initiating the FBLoginView");
return YES;
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
NSLog(@"Print 3");
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
NSLog(@"Print 4");
}
return self;
}
- (void)loginViewFetchedUserInfo:(FBLoginView *)loginView user:(id<FBGraphUser>)user {
NSLog(@"Print 5");
}
- (void)loginViewShowingLoggedInUser:(FBLoginView *)loginView {
NSLog(@"Print 6");
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
NSLog(@"Print 7");
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
我不确定我要放置readPermissions
的位置,但我几乎尝试了所有东西。我也尝试了不同的东西,比如
FBLoginView *loginView = [[FBLoginView alloc] init];
loginView.readPermissions = @[@"basic_info", @"email", @"user_likes"];
等等,但没有任何作用。现在,我已经通过loginView
将.h
与我的IBOutlet
文件相关联,但不确定它是否如何完成。 Facebook在线指南真的很糟糕......
任何人都可以帮助我吗?除了viewDidLoad
中的那个之外,为什么我的NSLog语句都没有打印出来?
答案 0 :(得分:2)
您忘记分配登录方法的委托属性。你需要
self.loginView.delegate = self;
或者永远不会调用委托方法