简体   繁体   English

Facebook SDK更改为在弹出视图中登录

[英]Facebook SDK changes to Login in Pop-up view

I am Trying to Login my app with Facebook.For that reason I have Installed Facebook SDK . 我正在尝试用Facebook登录我的应用程序。因此我安装了Facebook SDK now Problem is I am trying to start with SAMPLEs code of SDK ie SessionLoginSample .Problem is, to login Its takes me to the SAFARI to enter credientials.isn't it possible to open the login Page like PopUP View like(image 2)... 现在问题是我试图从SDK的SAMPLEs代码开始,即SessionLoginSample .Problem是,登录它带我到SAFARI输入credientials.is不可能像PopUP View那样打开登录页面(图2)。 ..

输入图像输入 Image 1 is coming directly (SAFARI ) ..what changes required to open it like (image 2) pop up. 图像1直接进入(SAFARI)..弹出它需要进行多少更改(图像2)。

 - (IBAction)buttonClickHandler:(id)sender {

SLAppDelegate *appDelegate = [[UIApplication sharedApplication]delegate];


if (appDelegate.session.isOpen) {

    [appDelegate.session closeAndClearTokenInformation];

} else {
    if (appDelegate.session.state != FBSessionStateCreated) {

        appDelegate.session = [[FBSession alloc] init];
    }


    [appDelegate.session openWithCompletionHandler:^(FBSession *session, 
                                                     FBSessionState status, 
                                                     NSError *error) {
        // and here we make sure to update our UX according to the new session state
        [self updateView];
    }];
} 
 }

Use FBConnect for that see this bellow tutorial... 使用FBConnect看看这个波纹管教程......

iPhone-fbconnect-facebook-connect-tutorial iPhone-fbconnect - Facebook的连接教程

see the Login Dialog like bellow... 看下面的登录对话框......

在此输入图像描述

Just follow the instruction and create your id and use it.. 只需按照说明创建您的ID并使用它..

Same but another tutorial with example see ... 相同但另一个教程与示例见...

This 这个

You can use this for your session: 您可以将此用于您的会话:

FBSession setActiveSession:[[FBSession alloc]initWithAppID:nil permissions:@[@"email", @"user_friends"] urlSchemeSuffix:@"foo" tokenCacheStrategy:nil]];

More information here: Developers Facebook 更多信息: 开发者Facebook

在文件info.plist中的XCode项目中,使用键“FacebookUrlSchemeSuffix”和字符串值查找或创建行。

Try this its working fine for me:: 试试这个对我来说工作正常::

loginView.loginBehavior=FBSessionLoginBehaviorForcingWebView;

Here loginView is my FBLoginView.This is for your right side screen shot. 这里loginView是我的FBLoginView。这是你的右侧屏幕截图。

For Screen shot 1 use following code: 对于屏幕截图1,请使用以下代码:

loginView.loginBehavior=FBSessionLoginBehaviorForcingSafari;
  let loginView : FBSDKLoginButton = FBSDKLoginButton()

  loginView.loginBehavior = FBSDKLoginBehavior.Web

It works for me, this is the source code in class FBSDKLoginManager: 它适用于我,这是类FBSDKLoginManager中的源代码:

public enum FBSDKLoginBehavior : UInt {

/*!
 @abstract Attempts log in through the native Facebook app. If the Facebook app is
 not installed on the device, falls back to \c FBSDKLoginBehaviorBrowser. This is the
 default behavior.
 */
case Native
/*!
 @abstract Attempts log in through the Safari browser
 */
case Browser
/*!
 @abstract Attempts log in through the Facebook account currently signed in through Settings.
 If no Facebook account is signed in, falls back to \c FBSDKLoginBehaviorNative.
 */
case SystemAccount
/*!
   @abstract Attemps log in through a modal \c UIWebView pop up

   @note This behavior is only available to certain types of apps. Please check the Facebook
   Platform Policy to verify your app meets the restrictions.
   */
case Web

} }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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