iOS WebApp 的 FB.login 中断流程 [英] FB.login broken flow for iOS WebApp

查看:29
本文介绍了iOS WebApp 的 FB.login 中断流程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个 iOS 网络应用程序(即,一个在独立模式下运行的 HTML 页面 - 没有 Safari chrome - 当页面的书签被添加到主屏幕时).

I'm making an iOS Webapp (i.e. an HTML page that runs in standalone mode - none of the Safari chrome - when the bookmark of the page is added to the homescreen).

我有一个按钮,onclick 调用 FB.login().在独立模式下,webapp 重定向到 facebook 登录页面(如预期的那样),但是之后,我被卡在白屏上(我没有被要求进行身份验证,因为我已经有了,但我想身份验证屏幕会发生在白屏之前)并且不要放回网络应用程序中.

I have a button that onclick calls FB.login(). When in standalone mode, the webapp redirects to the facebook login page (as expected), however afterwards, I get stuck on a white screen (I don't get asked to authenticate since I already have, but I imagine that the authentication screen would happen before the white screen) and don't get put back into the webapp.

Safari 应用程序中的相同流程按预期工作.单击登录会调用 FB.login(),这会打开一个新页面,要求您在其中登录 Facebook,一旦您登录并验证应用程序,该页面就会关闭,您将被放回原始页面.

The same flow within the Safari app works as expected. Clicking login calls FB.login(), which opens a new page where you are asked to login to Facebook, once you login and authenticate the app, that page closes and you are put back into the original page.

似乎在独立模式下,第二页"存在问题,FB 登录关闭并重定向回应用程序(它没有).并且流程中断了.

It seems that in standalone mode, there's a problem with the "second page" with the FB login closing and redirecting back to the app (it doesn't). And the flow is broken.

有什么解决方法吗?

谢谢,
-Esa

Thanks,
-Esa

推荐答案

您可以尝试以下解决方法.它对我有用.在移动设备中,它重定向到客户端身份验证 url.

You can try the workaround below. It worked for me. In mobile, it redirects to client side authentication url.

var isMobile = false;
try {
    isMobile = (window.location.href == top.location.href && window.location.href.indexOf("/mobile/") != -1);
} catch (e) {}
if (!isMobile) {
    FB.login();
} else {
    var permissionUrl = "https://m.facebook.com/dialog/oauth?client_id=" + appId + "&response_type=code&redirect_uri=" + redirectPage + "&scope=" + permissions;
    window.location = permissionUrl;
    return;
}

这篇关于iOS WebApp 的 FB.login 中断流程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆