react-native-fbsdk获取user_birthday并且user_location权限不起作用

时间:2017-11-09 15:53:03

标签: facebook react-native permissions location fbsdk

大家 我将使用react-native-fbsdk从Facebook获得生日和位置。

这是我的代码的一部分:

LoginManager.logInWithReadPermissions(['public_profile', 'user_birthday', 'user_location'])
        .then((result) => {
          if (result.isCancelled) {
            return;
          }
          AccessToken.getCurrentAccessToken().then((data) => {
              console.log(data); // output 1:
              const responseInfoCallback = (error, profile) => {
                if (error) {
                  console.log(error);
                } else {
                  console.log(profile); // output 2:
                }
              };
              const accessToken = data.accessToken;
              const infoRequest = new GraphRequest(
                '/me',
                {
                  accessToken,
                  parameters: {
                    fields: {
                      string: 'name,gender,birthday,location{location}',
                    },
                  },
                },
                responseInfoCallback,
              );
              new GraphRequestManager().addRequest(infoRequest).start();
            });
          });
        })
        .catch(error => console.log(error));
Here's result of output 1 and 2
--------- output 1 -------
{ accessToken: .......,
          permissions: [ 'email', 'public_profile' ],
          declinedPermissions: [],
          applicationID: '968214779983507',
          accessTokenSource: undefined,
          userID: '161823674419561',
          expirationTime: 1515417067593.333,
          lastRefreshTime: 1510242607593.949 }
-------output 2--------
{ id: '161823674419561', gender: 'male', name: '....' }

请帮帮我。 感谢。

1 个答案:

答案 0 :(得分:0)

这些权限仅适用于在App中具有角色的用户。如果您想让它们适用于其他所有人,则需要完成审核流程:https://developers.facebook.com/docs/facebook-login/review