In meinem ViewcontrollerfbdidLogin genannt nie
- (IBAction)loginBtn:(id)sender
{
facebook = [[Facebook alloc] initWithAppId:@"231190276934148" andDelegate:self];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
if ([defaults objectForKey:@"FBAccessTokenKey"] && [defaults objectForKey:@"FBExpirationDateKey"]) {
facebook.accessToken = [defaults objectForKey:@"FBAccessTokenKey"];
facebook.expirationDate = [defaults objectForKey:@"FBExpirationDateKey"];
}
if (![facebook isSessionValid]) {
NSArray *permissions = [[NSArray alloc] initWithObjects:
@"user_likes",
@"user_about_me",
@"user_photos",
@"friends_about_me",
@"friends_activities",
@"read_stream",
@"publish_stream",
nil];
[facebook authorize:permissions];
}
NSLog(@"asdoiffijd");
}
- (IBAction)btnRequest:(id)sender
{
[facebook requestWithGraphPath:@"me/friends" andDelegate:self];
}
- (void)fbDidLogin
{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:[facebook accessToken] forKey:@"FBAccessTokenKey"];
[defaults setObject:[facebook expirationDate] forKey:@"FBExiprationDateKey"];
[defaults synchronize];
NSLog(@"fbDidLogin!");
}
In meinem AppDelegate
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
return [facebook handleOpenURL:url];
}
Ich denke - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
vor dem fbdidLogin
genannt werden sollte, aber ich kann diesen Teil nicht vollständig [facebook handleOpenURL:url];
in Stackoverflow [[controller facebook] handleOpenURL:url];
löst Problem, , aber ich kann das nicht tun. Irgendeine Lösungsmöglichkeit?
Ja .. Ich habe versucht in AppDelegate und es hat wirklich funktioniert. kann ich aber die taste für die FB-Anmeldung in AppDelegate machen? –
Nein, aber in deinem View-Controller kannst du eine Zeile haben, die etwas wie 'YourAppDelegate * appDelegate = (YourAppDelegate *) [UIApplication sharedApplication] .delegate; 'sagt und dann kannst du dein Facebook-Objekt oder seine Methoden an diesem Punkt benutzen. – Rob