简体   繁体   中英

iOS Facebook login integration

I'm trying to do an iOS - FB integration.
I noticed that some apps like Instagram, when you try to integrate Facebook to the app, it actually takes you away from your app and opened up Facebook app.
However, the Facebook example that I downloaded from the FB site actually shows up a popup, and I do have to re-login, even though I already have Facebook app installed.

How can I achieve the Instagram implementation? Is it a setting on the FB app page? Or is that achieved through code?
Also what is the keyword of it so I can search on Google.

Thank you,
Tee

Just use Facebook SDK. Call FBSession 's openActiveSessionWithReadPermissions:allowLoginUI:completionHandler: method, SDK will do the rest. If there is an iOS integrated Facebook account, then only alert will be shown, no application switching. If there is no integrated account, but Facebook app is installed, then authorization will be provided via the Facebook application. No account and no app == authentication via web browser.

Use  

(BOOL)openActiveSessionWithPublishPermissions:(NSArray*)publishPermissions
                                defaultAudience:(FBSessionDefaultAudience)defaultAudience
                                   allowLoginUI:(BOOL)allowLoginUI
                              completionHandler:(FBSessionStateHandler)handler ,





 Make your Permission as array 


-(IBAction)actionSignUpWithFacebook:(id)sender {

[self openSessionWithAllowLoginUI:YES];

}


-(BOOL)openSessionWithAllowLoginUI:(BOOL)allowLoginUI {

    NSArray *permissions = [[NSArray alloc] initWithObjects:@"user_likes",
                            @"read_stream",
                            @"email",
                            @"user_about_me",
                            @"basic_info",
                            @"user_birthday",
                            @"user_location",
                            @"user_likes",nil];

return [FBSession openActiveSessionWithPublishPermissions:permissions                                        
                                          defaultAudience:FBSessionDefaultAudienceFriends
                                             allowLoginUI:allowLoginUI
                                        completionHandler:^(FBSession *session,FBSessionState state,NSError *error) {

                     [self sessionStateChanged:session
                                         state:state
                                         error:error];

                     [self getUSerDetailsFromFacebook];

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