5

I am creating one application which show Facebook friend. First, user need to click on login button then one simple popup screen will appear after filling login id and password it will show friend list.
Everything ok and run on Firefox, Chrome,IE but it will not open popup in Safari and iPhone.
someone suggest me add domain name and channel name in channelUrl. I create one channel.html and add reference but it didn't help me.
I search lot's but didn't find helpful.

Here is my code.
Custom.js

function getUser()
{
FB.init({
    appId      : '289403314507596', // App ID
    channelUrl : 'http://bc2-236-161.compute-1.amazonaws.com/html/channel.html', // Channel File
    status     : true, // check login status
    cookie     : true, // enable cookies to allow the server to access the session
    xfbml      : true  // parse XFBML
});

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

//check current user login status
FB.getLoginStatus(function(response) {
    if (response.status === 'connected') {
        window.location="facebook_friend.html"
        loadFriends();
    } else {
        //user is not connected.
        FB.login(function(response) {
            if (response.authResponse) {
                window.location="facebook_friend.html"
                loadFriends();
            } else {
                alert('User cancelled login or did not fully authorize.');
            }
        });
    }
 });
 }
//start from here
 $(document).ready(function(){
$('.load-button').click(function(){
    getUser();
});
});   

channel.html

<script src="//connect.facebook.net/en_US/all.js"></script>// i add this line in channel.html

refer_friend.html
I add reference of custom.js in this file

 <div id="fb-root"></div>
   <script src="http://connect.facebook.net/en_US/all.js"></script>
   <img src="includes/fb-btn1.png" class="load-button" style="
    width: 290px;
    Height: 40px;
    margin-top: 5px;"/>
tshepang
  • 12,111
  • 21
  • 91
  • 136
Sandip Armal Patil
  • 6,241
  • 21
  • 93
  • 160

1 Answers1

5

Ok... After wasting my full day i got a answer. Using Javascript_Facebook Sdk, when you click on Login button, it will open popup window. And in Safari or iPhone(mine), i enable Block-popup option.
Therefore i am not able to see Facebook login window. you need to allow pop-up window.
You can allow pop-up by clicking on

Safari-disable Block pop-up windows  

or

 safari-preference-then disable checkbox of pop-up window's    

or You can use a keyboard shortcut:

shift-[command key]-K.

cheers.

Sandip Armal Patil
  • 6,241
  • 21
  • 93
  • 160
  • 4
    The main problem with your code is that you call `FB.login`automatically – then the popup is very likely to get block by current browser. The general recommendation is to only call this method on explicit user interaction, e.g. clicking a link/button to trigger login. – CBroe Sep 20 '12 at 09:41
  • Safari seems to be very sensitive. same happens if you would call FB.getLoginStatus in above code inside a click handler. Currently experiencing this in Safari Version 6.0.5 (7536.30.1). I think its because FB.login is called inside a function, even if triggered/called by a user click event... – Björn Oct 08 '13 at 06:09
  • In my case I had it inside a click handler and it still wasn't opening. Problem was the layout of the page hid the button off screen until some other user interaction took place first. That's why safari's security settings prevented the popup. So also make sure you have the button visible that is meant to trigger the popup. –  Jan 12 '15 at 20:42