简体   繁体   中英

Facebook Connect open the Facebook App

i am trying to implement the facebook connect on my iphone App.

after the first confirm the app stay in the facebook app and dont return to my app.

i call the dialog methood from the view controller with a button but i want to post a message about the app when the user logs in how can i do it?

- (void)viewDidLoad{
    [super viewDidLoad];
    facebook = [[Facebook alloc]initWithAppId:@"" andDelegate:self];

    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    if ([defaults objectForKey:@"FBAccessTokenKey"] 
        && [defaults objectForKey:@"FBEpirationDateKey"])
    {
        facebook.accessToken = [defaults objectForKey:@"FBAccessTokenKey"];
        facebook.expirationDate = [defaults objectForKey:@"FBExpirationDateKey"];
    }

    if (![facebook isSessionValid]) {
        [facebook authorize:nil ];
    }
}

-(void)fbDidLogin{
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    [defaults setObject:[facebook accessToken] forKey:@"FBAccessTokenKey"];
    [defaults setObject:[facebook expirationDate] forKey:@"FBExpirationDateKey"];
    [defaults synchronize];
}

-(IBAction)dialog:(id)sender{
    [facebook dialog:@"feed" andDelegate:self];
}

TNX!

To disable this behavior modify Facebook.m line 275 and set both options to NO.

- (void)authorize:(NSArray *)permissions {
  self.permissions = permissions;

  // with both options NO, authorization always happens in-app
  [self authorizeWithFBAppAuth:NO safariAuth:NO];
}

In your app delegate you need to implement (make sure you keep a reference to the facebook class instance somewhere where it can be accessed by your app delegate):

- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url 
{
    return [facebook handleOpenURL:url];
}

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM