how to link the facebook signin in our ionic app using app42 social service?

0 votes

controller.js CODE
 

$scope.FBLogin = function(){
FB.login(function(response) {
if (response.authResponse) {
console.log('Welcome!  Fetching your information.... ');
FB.api('/me', function(response) {
console.log('Good to see you, ' + response.name + '.');
console.log(response);
 var fbresponse = FB.getAuthResponse();
 console.log(fbresponse.userID);
 var userName = fbresponse.userID,  
accessToken = fbresponse.accessToken,                    
social ;  
console.log("username.."+userName);
                     console.log("at.."+accessToken);
var socialService  = new App42Social();  
socialService.linkUserFacebookAccount(userName, accessToken,{  
success: function(object) { 
                       console.log("object.."+JSON.stringify(object));
var response = JSON.parse(object);    
social = response.app42.response.social;  
console.log("userName is " + social.userName)  
console.log("fb Access Token is " + social.facebookAccessToken)  
$state.go('tabsController.home');
},  
error: function(error) { 
                      console.log("error..;"+error);
}  
});
});
} else {
console.log('User cancelled login or did not fully authorize.');
}
});
}
 
html CODE
 
    @@@            <button id="login-facebook" style="font-size:15px;border-radius:5px 5px 5px 5px;" class="button button-positive button-block" ng-click="FBLogin()">facebook login</button>  @@@@
 

app.js CODE 

window.fbAsyncInit = function() {
    FB.init({
      appId      : '1663410043984668',
      xfbml      : true,
      version    : 'v2.7'
    });
  };
 
  (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/sdk.js";
     fjs.parentNode.insertBefore(js, fjs);
   }(document, 'script', 'facebook-jssdk'));

 

asked Jul 21, 2016 in JavaScript by anjireddy1245 (10 points)
edited Jul 21, 2016 by anjireddy1245

1 Answer

0 votes
Hi,

It looks like your code is correct. If you are getting any exception on calling linkUserFacebookAccount, then share your error message with us.

It will help us debug the problem.

Regards,

Rajeev
answered Jul 22, 2016 by rajeev.etc (1,660 points)
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...