如何更改ios中FBSDKLoginButton中的默认登录按钮?

2024-05-22

如何自定义 Facebook 中的登录按钮?我不想使用 Facebook 默认登录按钮。


对于 SDK 4.0:

您应该添加一个按钮,并在按钮操作中使用以下代码:

- (IBAction)loginButtonClicked:(id)sender {

   FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
   [login logInWithReadPermissions:@[@"email"] handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
        if (error) {
            // Process error
            NSLog(@"error %@",error);                
        } else if (result.isCancelled) {
            // Handle cancellations
           NSLog(@"Cancelled");
        } else {
           if ([result.grantedPermissions containsObject:@"email"]) {
                // Do work
                NSLog(@"%@",result);
                NSLog(@"Correct");
            }
        }
    }];
}

更新 :接收用户信息

 - (IBAction)loginButtonClicked:(id)sender {

       FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
       [login logInWithReadPermissions:@[@"email"] handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
            if (error) {
                // Process error
                NSLog(@"error %@",error);                
            } else if (result.isCancelled) {
                // Handle cancellations
               NSLog(@"Cancelled");
            } else {
               if ([result.grantedPermissions containsObject:@"email"]) {
                    // Do work
                     [self fetchUserInfo];
                }
            }
        }];
    }

-(void)fetchUserInfo {

    if ([FBSDKAccessToken currentAccessToken]) {

    NSLog(@"Token is available");

    [[[FBSDKGraphRequest alloc] initWithGraphPath:@"me" parameters:nil]
     startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
         if (!error) {
             NSLog(@"Fetched User Information:%@", result);

         }
         else {
             NSLog(@"Error %@",error);
         }
     }];

    } else {

        NSLog(@"User is not Logged in");
    }
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何更改ios中FBSDKLoginButton中的默认登录按钮? 的相关文章

随机推荐

  • 由于 maven-surefire-plugin,Maven 构建失败

    我这里有类似的问题eclipse 中缺少 maven surefire plugin https stackoverflow com questions 23588957 maven surefire plugin missing in e
  • 尚不支持将 struct memory[] 类型内存复制到存储

    如何将新的空父实例添加到下面代码示例中的父实例列表中 我不断得到 UnimplementedFeatureError Copying of type struct Test Child memory memory to storage no
  • 如何向 UITableView 添加项目?

    我正在尝试将项目添加到UITableView有一个按钮 这是我的代码 In viewDidLoad repository NSMutableArray alloc initWithObjects nil ADD ITEM TO LIST r
  • 无法连接到 EC2 - ssh:连接到主机端口 22:连接被拒绝

    我目前在海外 尝试通过 ssh 连接到我的 EC2 实例 但收到错误ssh connect to host ec2 34 207 64 42 compute 1 amazonaws com port 22 Connection refuse
  • 如何在 WordPress 中获取帖子中的类别标题?

    假设我在 WordPress 中有一篇名为 Hello World 的帖子 并且我直接查看此页面 我将如何找到 Hello World 类别并显示它 Use get the category http codex wordpress org
  • WooCommerce 从前端(而不是管理员)隐藏订单项元

    我有一些我不希望客户看到的订单项元详细信息 在帐户信息下的查看订单页面上 我找到了一个过滤器 可以从管理员 我仍然希望看到它 中删除这些数据 但找不到类似的过滤器来从前端 应该隐藏它 中删除它 这是将从后端管理中删除它的代码 对我来说毫无用
  • 在 Swift 中动态设置 Dictionary 的属性

    我正在尝试根据字典中的值在类上设置一些属性 目前我正在这样做 let view UIView UIView if let hidden Bool self props hidden as Bool view hidden hidden if
  • 如何使用Excel的墨迹工具添加手写签名?

    我想在我公司的一些表格中添加手写数字签名 目标是选择一个文档 添加签名 通过使用绘图板 这可以使用 Excel 的墨水工具完成 并将文件作为 PDF 存储在服务器中 这将消除打印然后扫描表格以获得签名的必要性 我使用 Excel 作为文件操
  • html 元视口标签

    我建立了一个html登陆页面 你可以看到它here http tzabar exactive co il 我以这种方式使用元视口标签 当我从手机进入这个页面时 页面宽度不适合屏幕 iPhone 示例 http mobiletest me i
  • 英特尔融核上的 MKL 性能

    我有一个例程 对小矩阵 50 100 x 1000 个元素 执行一些 MKL 调用以拟合模型 然后我调用不同的模型 在伪代码中 double doModelFit int model while done cblas dgemm cblas
  • 如何使用 RSpec 测试 javascript 重定向?

    我正在使用 xhr post 与控制器交互 并且我期待重定向 在 js erb 中 我有 window location href address 手动测试 浏览器会正确重定向 我如何使用 RSpec 测试它 response should
  • 如何记录所有抛出的异常?

    如何记录抛出和捕获的任何异常 就像 Visual Studio 的 IntelliTrace 所做的那样 或者有没有办法将 InteliTrace 集成到应用程序的调试版本中 然后查看其日志 Update 我会稍微澄清一下 我想要标准 tx
  • 如何设置Codeigniter上传库在本地机器的上传路径?

    我将以下路径设置为 Codeigniter 附带的上传库的 upload path this gt upload config upload path uploads working 该路径在远程服务器上运行良好 但是 当我在本地调试时 它
  • Maven 插件前缀解析如何工作?为什么它解决了“findbugs”而不是“jetty”?

    我正在使用 Maven 进行一些测试 并意识到我可以执行findbugsFindbugs 插件的目标 无需将插件添加到 POM 文件 另一方面 当我需要运行runJetty 插件的目标 我被迫将插件添加到 POM 文件中 否则构建失败 为什
  • 用于全文搜索和 2 亿多条记录的数据库

    我即将创建一个包含至少 2 亿个条目的庞大数据库 数据库需要可使用全文进行搜索 并且速度应该很快 我的数据库从许多不同的数据源获取数据 我需要定期导入新的或更新的数据 将我的所有数据存储在像 mysql 这样的关系数据库中 然后创建一个 n
  • Mercurial 与 Visual Studio 2010 的白痴清单

    所以我是一个源代码控制白痴 所以请用这个清单来幽默我 我最终决定使用Mercurial TortoiseHg VS2010 HgScc包 http bitbucket org zzsergant hgsccpackage wiki Home
  • (发件人:TObject)

    发件人 TObject 是什么意思 如 procedure TForm1 Button1Click Sender TObject var s Integer begin end Sender 是对触发事件的组件的引用 在这种情况下 Send
  • Android 缩放和密度问题

    Update 一些研究表明 华硕 Transformer TF700T 高端 的像素密度应约为 224 因此 android 报告的 159 值要么是错误的 要么已被某种方式修改 system 中的 lcd 密度键 build prop 由
  • Spring Security 的 AJAX 请求给出 403 Forbidden

    我有一个基于spring boot spring security thymeleaf的网站 在某些情况下我也使用ajax 问题 我在 Spring Security 中使用表单登录安全性 在浏览器中 登录后我可以使用rest API GE
  • 如何更改ios中FBSDKLoginButton中的默认登录按钮?

    如何自定义 Facebook 中的登录按钮 我不想使用 Facebook 默认登录按钮 对于 SDK 4 0 您应该添加一个按钮 并在按钮操作中使用以下代码 IBAction loginButtonClicked id sender FBS