FB.login破解了iOS WebApp的流程 [英] FB.login broken flow for iOS WebApp

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

问题描述

我正在制作一个iOS Web应用程序(即一个以独立模式运行的HTML页面 - 没有Safari浏览器 - 当页面的书签添加到主屏幕时)。

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登录页面(正如预期的那样),但之后,我被卡在白色屏幕上(我没有被要求进行身份验证,因为我已经有了,但我想,验证屏幕会发生在白色屏幕之前)并且不会被放回到webapp中。

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

推荐答案

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

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;
}

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

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