【问题标题】:retrieve fb userid in iOS Xcode在 iOS Xcode 中检索 fb 用户 ID
【发布时间】:2016-05-07 01:54:48
【问题描述】:

随着 FB API 的新变化,我不知所措。 我有一个为用户使用 FB 登录的应用,但我不知道如何在登录后获取用户 ID 以填充应用内配置文件。

用户 ID 最终将被用于发起 fb-messenger 聊天。

新的更新取消了检索用户 ID 的功能,还是我错过了重要的一步?

【问题讨论】:

    标签: ios xcode facebook facebook-graph-api


    【解决方案1】:

    我将它用于我的应用程序,它仍然有效

    FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
        [login logOut];
        [login logInWithReadPermissions: @[@"public_profile"] handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
            if (error) {
                NSLog(@"Process error %@",[error localizedDescription]);
                [indicator setHidden:YES];
                [Helper showToast:[error localizedDescription] withDuration:1];
            } else if (result.isCancelled) {
                NSLog(@"Cancelled");
                [indicator setHidden:YES];
                [Helper showToast:@"You cancelled FB login" withDuration:1];
            } else {
                NSLog(@"Logged in");
                [FBSDKProfile enableUpdatesOnAccessTokenChange:TRUE];
                if ([[FBSDKAccessToken currentAccessToken] tokenString]) {
                    [[[FBSDKGraphRequest alloc] initWithGraphPath:@"me" parameters:nil]
                     startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
                         if (!error) {
                             DDLogDebug(@"%@",result);
                             DDLogDebug(@"token string = %@",[FBSDKAccessToken currentAccessToken].tokenString);
                             DDLogDebug(@"user id = %@",[FBSDKAccessToken currentAccessToken].userID);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-08-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-12
      • 1970-01-01
      相关资源
      最近更新 更多