0
votes

Im trying to include facebook login to my phonegap application. I have used the https://github.com/Wizcorp/phonegap-facebook-plugin.git plugin for this. Im getting the error like this when i try to test the login in my phone:

"given url is not allowed by the application configuration one or more of the given urls isnot allowed by the apps settings. to use this url you must add a valid native platform in your apps settings"

Code:

$("#fbbtn-login").click(function(){ 
    facebookConnectPlugin.getLoginStatus(function(data){ 
        console.log(data);
        if(data.status == "connected"){
            //alert('Already logged in');
            apiTest();
        }else{
            // goto login
        }           
    },function(e){ console.log(e);});

facebookConnectPlugin.login(["public_profile"], function(data){
    console.log(data);
    console.log('login success');
    //alert(JSON.stringify(data));
}, function(e){             
    console.log(e);         
});

//var facebook_email;

var apiTest = function () {
    //alert("email");
    facebookConnectPlugin.api( "me/?fields=id,email",
        function (response) {
            alert(JSON.stringify(response));
            // localStorage.setItem('facebook_email', response.email);
            //alert(facebook_email);
            //  localStorage.setItem("facebook_flag","1");
            //alert(facebook_flag);
            //  window.location="getting-started.html";
            //alert("after navigation");
        },
        function (response) { 
            //alert(JSON.stringify(response)); 
        }); 
    }
});    
4

4 Answers

0
votes

Sounds like a facebook app configuration problem. Did you set up the facebook login in the app and did you ad an android and ios platform in the facebook app?

For android you need to generate a key for example.

You can use that link to guide you through the process: https://developers.facebook.com/quickstarts/1594234934213595/?platform=android

0
votes

Follow these steps

go to developer.facebook.com into your app setting select 'Add platform' chose 'website' put http://localhost/callback as Site URL

This should work now

0
votes

First of all create a facebook developer account and get the app id and name. Then go to settings and add the platform you need. If its android then add the Google Play Package Name,Class Name and Key Hash. For iOS add the buldle id. After this you can implement the plugin https://github.com/Wizcorp/phonegap-facebook-plugin.git .

0
votes

I got the perfect solution for this guys.. Use this plugin: https://github.com/Wizcorp/phonegap-facebook-plugin

add facebook cordova plugin using below command

cordova plugin add https://github.com/Wizcorp/phonegap-facebook-plugin --variable APP_ID="YOURAPPID" --variable APP_NAME="YOURAPPNAME"

html code

Javascript code

function fblogin(){

        facebookConnectPlugin.login( ["public_profile","email"],
            function (response) {

                if(response.authResponse.userID!=''){
                    facebookConnectPlugin.api(response.authResponse.userID+"/?fields=id,email,first_name", ["public_profile"],
                    function (response) {
                        console.log('SUCCESS:'+response);
                        alert('first_name : '+response.first_name+',email:'+response.email+',id:'+response.id);
                    },
                    function (response) {
                        console.log('ERROR:'+response);
                    });
                }    

            }, 
            function (response) {   
                    console.log('ERROR:'+response);
           });

           }

           </script>`