Ionic Cordova AngularJs:为什么Facebook分享可以在Ionic服务(浏览器)中工作,而不能在



通过下面的代码,它与"ionic serve"(浏览器)一起工作,当我点击"Facebook共享按钮"时,我得到一个"Facebook窗口弹出",我可以毫无问题地共享数据。

当我在我的Android设备上测试时,我点击了"Facebook分享按钮",什么都没有发生!我在控制台中使用"chrome://inspect/#devices"

时没有出现错误。
  1. 我的"Facebook弹出窗口"是否在设备上被阻止?
  2. 为什么设备上没有显示

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>

谢谢

这是我能找到的最好的解决方案:

我使用了这个源代码(仔细查看你能做什么和不能做什么)https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin/blob/master/README.md

在Ionic Front中,我调用url
$scope.urlFacebook = function(){
  var urlFb = "http://www.troubadourstory.fr/App/fb_share/" + $scope.point._id;
  window.plugins.socialsharing.share(null, null, null, urlFb);   
};

在后面我使用这样的Html元数据

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html xmlns:fb="http://www.facebook.com/2008/fbml" xmlns:og="http://opengraphprotocol.org/schema/" class="">
  <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <meta http-equiv="imagetoolbar" content="no">
    <title>J'ai visité "<%= dataPoi.Poi.title %>" avec l'application mobile Troubadour Story !</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache,must-revalidate">
    <meta http-equiv="expires" content="0">
    <meta property="og:image" content="<%= dataPoi.Poi.picture %>" height="150px" width="150px">
    <meta name="keywords" content="<%= dataPoi.Poi.title %>">
    <meta name="description" content='Présenté par "<%= dataPoi.Poi.user.username %>" : <%= dataPoi.Poi.content %>'>
  </head>

你可以用这个链接从HTML meta测试你的URLhttps://developers.facebook.com/tools/debug

希望能有所帮助;-)

最新更新