iphone - Facebook 登录按钮需要点击两次才能在 Safari / iPhone 中工作,为什么?
问题描述
我在我的网站中使用默认的 Facebook 登录按钮。它适用于所有桌面浏览器,它也适用于我的带有 Firefox 和 Chrome 的 iPhone。但是,当我使用 Safari 时,我必须在按钮上单击两次才能发送请求。
我听说 Safari 普遍存在这个问题。有人对此有解决方案吗?
这是我使用的代码:
function getInfos() {
FB.api('/me', {fields: 'first_name,last_name,email,id'}, function(response) {
var fn = ('first_name' in response) ? response.first_name : "null";
var ln = ('last_name' in response) ? response.last_name : "null";
var fid = ('id' in response) ? response.id : "null";
var mail = ('email' in response) ? response.email : "null";
// ... SUCCESS!! and whatever you want to do with the FB data...
});
}
function processLoginStatus(response) {
if (response.status === 'connected') {
getInfos();
} else {
FB.login(function(response) {
if (response.authResponse) {
processLogin(response);
} else {
// user clicked cancel
}
}, {scope: 'public_profile,email'});
}
}
function processLogin(response) {
if (response.status === 'connected') {
getInfos();
} else if (response.status === 'not_authorized') {
console.log("processLogin: not authorized");
} else {
console.log("processLogin: else");
}
}
function checkLoginState() {
FB.getLoginStatus(function(response) {
processLoginStatus(response);
});
}
$(document).ready(function() {
if ($('.facebooklogin').length != 0) {
if (typeof FB === 'undefined' || FB === null) {
} else {
FB.init({
appId : 'MYAPPID',
cookie : true,
xfbml : true,
version : 'v7.0'
});
$('button.facebooklogin').click(function() {
checkLoginState();
});
}
}
});
解决方案
推荐阅读
- powershell - tf 获取特定分支
- r - 如何修复为 R 中的列返回 na 的 factor() 函数
- algorithm - 具有步行代理的“最短路径”算法
- image-processing - 如何从位图图像中提取平方根符号?
- azure-cognitive-search - 我可以使用基于 Edm.DateTimeOffset 字段年份的过滤器和构面吗
- c++ - 不需要括号或引用的成员别名的 C++ 标准方式?
- ag-grid - aggrid:没有可用于绘制图表的数据
- python - 在 PyTorch 张量中查找等于零的元素索引
- java - Java中的Dijkstra算法和源代码更改
- angular - 动态添加验证器