草庐IT

javascript - react-native loginwithpermissions promise 在 android 上没有解决

coder 2023-12-23 原文

将 react-native 从 0.56 升级到 0.59.8(使用 FBSDK 0.10.1)后,facebook 登录不再适用于 android。

当我填写 Fb 登录表单并继续时,LoginManager.logInWithPermissions promise 不会解析并且永远不会在 logInWithPermissions() 之后转到 .then()

这是我的代码:

loginWithFBSDKLoginManager() {
    LoginManager.logOut();
    const self = this;
    return new Promise((resolve, reject) => {
      LoginManager.logInWithPermissions(['public_profile', 'email']).then(function (result) {
        if (result.isCancelled) {
          return;
        }
        AccessToken.getCurrentAccessToken().then((data) => {
          const accessToken = data.accessToken.toString();
          const userID = data.userID.toString();
          self
            .getUserInfos(accessToken)
            .then((response) => {
              resolve({ ...response, accessToken, userID });
            })
            .catch(
              function (error) {
                reject(error);
              }
            );
        });
      });
    });
  }

我几乎在所有地方都尝试设置断点,但没有任何帮助。 最奇怪的是,在 iOS 上完美运行,这个问题只发生在 Android 上。

我尝试使用 Android Studio 调试我的应用程序,但在控制台中发现的唯一错误是

I/chromium: [INFO:CONSOLE(0)] "Refused to display 'https://m.facebook.com/intern/common/referer_frame.php' in a frame because it set 'X-Frame-Options' to 'deny'.", source: https://m.facebook.com/v3.3/dialog/oauth?client_id=2129868160675609&e2e=%7B%22init%22%3A1562743341374%7D&sdk=android-5.0.3&scope=public_profile%2Cemail&state=%7B%220_auth_logger_id%22%3A%22edb48b96-de45-47e6-8331-f3db300e4eb2%22%2C%223_method%22%3A%22web_view%22%7D&default_audience=friends&redirect_uri=fbconnect%3A%2F%2Fsuccess&auth_type=rerequest&display=touch&response_type=token%2Csigned_request&return_scopes=true&ret=login&fbapp_pres=0&logger_id=edb48b96-de45-47e6-8331-f3db300e4eb2#= (0) I/chromium: [INFO:CONSOLE(53)] "ErrorUtils caught an error: "Script error.". Subsequent errors won't be logged; see https://fburl.com/debugjs.", source: https://static.xx.fbcdn.net/rsrc.php/v3iEpX4/ys/l/fr_FR/LDgA15LzuMu.js (53) I/chromium: [INFO:CONSOLE(262)] "Uncaught SecurityError: Blocked a frame with origin "https://m.facebook.com" from accessing a frame with origin "null". The frame requesting access has a protocol of "https", the frame being accessed has a protocol of "data". Protocols must match. ", source: https://static.xx.fbcdn.net/rsrc.php/v3iEpX4/ys/l/fr_FR/LDgA15LzuMu.js (262)

有人可以帮我解决这个问题吗?或指导我找到根本原因。

谢谢

最佳答案

我通过从 v0.10.1 升级到 v1.0.1 设法解决了这个问题。请记住删除 MainApplication.java

中的所有 CallbackManager 内容

关于javascript - react-native loginwithpermissions promise 在 android 上没有解决,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56966236/

有关javascript - react-native loginwithpermissions promise 在 android 上没有解决的更多相关文章

随机推荐