开发者

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:@"FBAccessTokenKe开发者_运维知识库y"] 
        && [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];
}


you should Modify the app property list file

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜