当使用javascript FB登录代码时,用于iPhone的Chrome和Safari浏览器应用程序的错误/空白页面 [英] Error/blank page with Chrome and Safar browser apps for iphone when using javascript FB login code

查看:109
本文介绍了当使用javascript FB登录代码时,用于iPhone的Chrome和Safari浏览器应用程序的错误/空白页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新:



此问题影响到Chrome和Safari浏览器应用程序。

使用以下代码在我的网站上使用Facebook登录(Javascript / Parse)。它在Chrome浏览器中运行正常。



Chrome应用程序问题


错误,不支持浏览器:Google Chrome for iOS不支持
此功能。请使用Safari并再试一次


它停在以下网址(我已将敏感数据更改为XXXX)。



https://m.facebook.com/dialog/oauth? APP_ID = XXXX&安培; CLIENT_ID = XXXX&安培;显示器=触摸和域= kudosoo.com&安培; E2E =%7B%7D&安培;语言环境= EN_US&安培;来源= 2及REDIRECT_URI = HTTP%3A%2F%2Fstatic.ak.facebook.com%2Fconnect %2Fxd_arbiter.php%3Fversion%3D40%23CB%3Df2562075ac%26domain%3DXXXX.com%26origin%3Dhttp%253A%252F%252Fkudosoo.com%252Ff3714a6424%26relation%3Dopener%26frame%3 Df2a549beb4& response_type = token%2Csigned_request& sdk = joey



Safari浏览器应用程序问题

停止在具有我的脚本执行登录脚本的页面上,即使浏览器刷新了它也不会移动通过此页面并且不会登录用户。






我在这里看过一些帖子 FB .login iOS WebApp的破解流,但不确定他们是否会解决它或放置代码?



我的代码如下所示:

 <!doctype html> 

<! - 运行使用Facebook身份验证的解析和FB代码将用户登录到站点并将其重定向到主内容区域。此网页是通过点击网站登录页面上的Facebook按钮触发的 - >


< html lang =en>
< head>
< meta charset =utf-8>
< meta name =apple-mobile-web-app-capablecontent =yes>
< meta name =apple-mobile-web-app-status-bar-stylecontent =black>

< title> Fb登入< / title>

< script type =text / javascriptsrc =http://www.parsecdn.com/js/parse-1.2.16.min.js>< / script>


< / head>
< body>

<! - 重要的是,必须在页面上 - >
< div id =fb-root>< / div>


<! - 初始化Parse对象 - >
< script type =text / javascript>
Parse.initialize(XXX,XXX);


// Fb应用信息//

window.fbAsyncInit = function(){
Parse.FacebookUtils.init({
appId:'XXX',
channelUrl:'http://XXXX/channel.html',
status:true,
cookie:true,
xfbml:true
});

// FB用户认证脚本,完成后触发todos_two.js将用户重定向到主内容页面//

Parse.FacebookUtils.logIn(null,{
成功:功能(用户){
if(!user.existed()){
alert(用户注册并通过Facebook登录!);
window.location .href =user_home.html;
} else {
alert(User logged in through Facebook!);
window.location.href =user_home.html;

},
错误:函数(用户,错误){
alert(用户取消了Facebook登录或未完全授权。);
}
});


};

(函数(d,s,id){
var js,fjs = d.getElementsByTagName(s)[0];
if(d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src =//connect.facebook.net/en_US/all.js; $ b $ (js,fjs);
}(document,'script','facebook-jssdk'));


< / script>

< / body>
< / html>


解决方案

错误消息很明显:


错误,不受支持浏览器:Google Chrome for iOS不支持此功能。请使用Safari并再试一次

Chrome不受支持。你必须使用Safari浏览器才能使用Facebook登录。



我假设你足够聪明,知道你真正想要的是为什么这是事实。这个问题的答案可以通过谷歌搜索找到。



Facebook OAuth不支持在iOS中使用Chrome浏览器



将我们引导至这里告诉我们,iOS中有一个错误,它阻止了它正常工作。



你可以通过使用基于重定向的登录流来解决这个问题: /手动建立一个登录流rel =nofollow noreferrer> https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow


UPDATE:

This issue is affecting both Chrome and safari browser apps.

I'm trying to use Facebook login (Javascript/Parse) on my site with the following code. It works fine in the PC browser.

Issue with Chrome app

Error, unsupported Browser: Google Chrome for iOS does not support this feature. Please use Safari and try again

It stops on the follwing url (Ive changed sensitive data to XXXX).

https://m.facebook.com/dialog/oauth?app_id=XXXX&client_id=XXXX&display=touch&domain=kudosoo.com&e2e=%7B%7D&locale=en_US&origin=2&redirect_uri=http%3A%2F%2Fstatic.ak.facebook.com%2Fconnect%2Fxd_arbiter.php%3Fversion%3D40%23cb%3Df2562075ac%26domain%3DXXXX.com%26origin%3Dhttp%253A%252F%252Fkudosoo.com%252Ff3714a6424%26relation%3Dopener%26frame%3Df2a549beb4&response_type=token%2Csigned_request&sdk=joey

Issue with safari app

It stops on the page that has my script to execute the login scripts, even with a browser refresh it does not move past this page and does not log the user in.


I've seen some posts here FB.login broken flow for iOS WebApp , but unsure if they will resolve it or where to place the code?

My code is as follows:

<!doctype html>

<!-- Runs Parse and FB code that uses Facebook authentication to login user to the site and redirects them to the main content area. This page is fired from the Facebook button being clicked on the site landing page-->


<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">

    <title>Fb Login</title>

    <script type="text/javascript" src="http://www.parsecdn.com/js/parse-1.2.16.min.js"></script>   


</head>
<body>

    <!-- Important, must be on the page -->
    <div id="fb-root"></div>    


    <!-- Initialize the Parse object-->
    <script type="text/javascript">     
    Parse.initialize("XXX", "XXX");


//Fb app information//

window.fbAsyncInit = function() {
    Parse.FacebookUtils.init({
        appId      : 'XXX',
        channelUrl : 'http://XXXX/channel.html',
        status     : true,
        cookie     : true,
        xfbml      : true
    });

//FB user authentication script, after this completes it fires todos_two.js to redirect user to main content page//

Parse.FacebookUtils.logIn(null, {
    success: function(user) {
        if (!user.existed()) {
            alert("User signed up and logged in through Facebook!");
            window.location.href="user_home.html";
        } else {
            alert("User logged in through Facebook!");
            window.location.href="user_home.html";
        }
    },
    error: function(user, error) {
        alert("User cancelled the Facebook login or did not fully authorize.");
    }
});


};

(function(d, s, id){
    var js, fjs = d.getElementsByTagName(s)[0];
    if (d.getElementById(id)) {return;}
    js = d.createElement(s); js.id = id;
    js.src = "//connect.facebook.net/en_US/all.js";
    fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));


</script>

</body>
</html>

解决方案

So in the comments you say you are using chrome. The error message is pretty clear:

Error, unsupported Browser: Google Chrome for iOS does not support this feature. Please use Safari and try again

Chrome is unsupported. You have to use safari to use Facebook login.

I'm going to assume that you're smart enough to have figured this out and that what you are really asking is WHY this is the case. The answer to that question is found by Googling.

Facebook OAuth "Unsupported" in Chrome on iOS

Leads us to here which tells us there is a bug in chrome for iOS that prevents it from working properly.

You can work around this issue by using a redirect based login flow with this documentation:

https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow

这篇关于当使用javascript FB登录代码时,用于iPhone的Chrome和Safari浏览器应用程序的错误/空白页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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