繁体   English   中英

Ionic Cordova AngularJs:为什么Facebook共享可以在Ionic服务(浏览器)中工作,但不能在Android Device中显示弹出窗口?

[英]Ionic Cordova AngularJs : Why Facebook share works in Ionic serve (browser) but not pop-up display in Android Device?

使用以下代码,它可以与“离子服务”(浏览器)一起使用,当我单击“ Facebook共享按钮”时,我将获得“ Facebook窗口弹出窗口”,并且可以毫无问题地共享数据。

当我在Android设备上进行测试时,我单击了“ Facebook共享按钮”,没有任何反应! 而且我在控制台中使用“ chrome:// inspect /#devices”没有任何错误

  1. 我的“ Facebook弹出窗口”在设备上被阻止了吗?
  2. 为什么未在设备上显示?
  3. 有任何想法吗 ?

在我的控制器中

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(){

在我看来

<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中,我称一个网址

$scope.urlFacebook = function(){
  var urlFb = "http://www.troubadourstory.fr/App/fb_share/" + $scope.point._id;
  window.plugins.socialsharing.share(null, null, null, urlFb);   
};

在后面,我像这样使用HTML meta

<!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>

您可以使用此链接 https://developers.facebook.com/tools/debug 从HTML meta测试您的URL

希望这可以帮助;-)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM