I am trying to use the following code (taken from the javascript FB.Login example) to bring up my own pop-ups in an FB iOS application so that the user can login and authenticate our application. The iOS mobile app is the main use case for our web application page. We use frames to allow customers to embed our code on their sites.
The example below works fine (and shows the correct native iOS pop-ups for Facebook) when it is directly accessible (fblogin.hml), but does not show pop-ups when it is accessible through an iframe. Any calls to FB.ui really work fine when called through an iframe. Is this the desired behavior or problem in the iOS app for Facebook and / or the Javascript SDK? Is there any other way that we can call FB.Login from iFrame?
login page:
... fblogin.html ..
<html>
<head>
<title>FB.Login example</title>
</head>
<body>
<script src = "//connect.facebook.net/en_US/all/debug.js"></script>
<div id="fb-root"></div>
<script type="text/javascript">
FB.init({
appId: 'YOUR_FACEBOOK_APP_ID',
xfbml: true,
status: true,
cookie: true,
});
FB.getLoginStatus(checkLoginStatus);
function authUser() {
FB.login(function(response) {
console.info('FB.login callback', response);
if (response.status === 'connected') {
console.info('User is logged in');
} else {
console.info('User is logged out');
}
}, {scope:'email'});
}
function checkLoginStatus(response) {
conole.log(response);
if(response && response.status == 'connected') {
alert('User is authorized');
document.getElementById('loginButton').style.display = 'none';
console.log('Access Token: ' + response.authResponse.accessToken);
} else {
alert('User is not authorized');
document.getElementById('loginButton').style.display = 'block';
}
}
</script>
<a href="https://www.facebook.com/dialog/oauth?client_id=YOUR_FACEBOOK_APP_ID&redirect_uri=http://THIS_URL">Login Using oauth URL</a>
<input id="loginButton" type="button" value="Login Using Javascript SDK" onclick="authUser();" />
</body>
</html>
Insert page
... fblogin_embed.html
<html>
<head><title>Facebook embed test</title>
</head>
<body>
<iframe src="fblogin.html"
frameborder="0"
scrolling="no"
width="100%"
height="100%">
</iframe>
</body>
Playback:
- Make sure your Facebook profile has not yet allowed your APP_ID.
- Create fblogin.html and post it somewhere. (remember to replace APP_ID and THIS_URL with your own values)
- fblogin_embed.html - ( , URL- iframe fblogin.html.
- fblogin.html fblogin_embed.html FB.
- fblogin.html iOS Facebook "" , . . "".
- fblogin_embed.html iOS Facebook . FB.Login.