With the following code, it works with "ionic serve" (browser), when I click on the "Facebook share button", I obtain a "Facebook window pop-up" and I can share datas without any problems.
When I test on my Android Device, I click on the "Facebook Share button", nothing's happen ! And I obtain no error in the console with "chrome://inspect/#devices"
In my Controller
window.fbAsyncInit = function() {
FB.init({
appId : 'xxxMyIdxxx',
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
};
(function() {
var e = document.createElement('script');
//e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
e.src="https://connect.facebook.net/en_US/all.js";
e.async = true;
document.getElementById('share_button').appendChild(e);
}());
$scope.shareFacebook = function(){
var titleShareFb = "myTitle1";
var imgShareFb = "http://www.example.com/img/1.jpg";
//e.preventDefault();
FB.ui({
method: 'feed',
name: titleShareFb,
link: 'http://www.example.com',
picture: imgShareFb,
caption: 'myCaption1',
description: 'myDescription1',
message: ''
});
}; //end of $scope.shareFacebook = function(){
In my View
<div id="cssShareFacebook">
<img ng-click="shareFacebook()" id="share_button" src="http://www.example.fr/img/facebookShare.png">
</div>
Thank you