简体   繁体   English

Phonegap + Facebook

[英]Phonegap + Facebook

I want to integrate a Facebook " like " button in my hybrid app with Facebook javascript SDK plugin. 我想在我的混合应用程序中将Facebook“ like ”按钮与Facebook javascript SDK插件集成在一起。 The " like " button works perfectly on a browser, but the like button doesn't show up when I build the project with Phonegap 3.7.0 and run it on Android(5.0) and iOS(8.1.2) like ”按钮在浏览器上可以正常使用,但是当我使用Phonegap 3.7.0构建项目并在Android(5.0)iOS(8.1.2)上运行该项目时,like按钮不会显示

I tried this: https://github.com/Wizcorp/phonegap-facebook-plugin/blob/master/platforms/pg-build/README.md but still no like button... 我尝试了这个: https : //github.com/Wizcorp/phonegap-facebook-plugin/blob/master/platforms/pg-build/README.md但还是没有喜欢的按钮...

I hope someone can help me, 我希望有一个人可以帮助我,

Thanks in advance! 提前致谢!

HTML: HTML:

<head>

    <meta charset="utf-8" />
    <meta name="viewport" content="initial-scale = 1.0">

    <script src="js/cordova/cordova.js" type="text/javascript"></script>
</head>

<body>

    <!-- Facebook SDK plugin -->
    <div id="fb-root"></div>


    <div class="uitje_detail_bot_content">
        <div class="uitje_detail_social_media">
            <table>
                <tr>
                    <td>
                        <div class="fb-like" data-href="http://www.mamyloe.nl/uitjes/{{uitje.id}}" data-layout="button_count" data-action="like" data-show-faces="false" data-share="false"></div>
                    </td>
                    <td>
                        <a href="https://twitter.com/share" class="twitter-share-button" data-url="http://www.mamyloe.nl/uitjes/{{uitje.id}}" data-text="{{uitje.title}} |" data-via="httpstwittercommamyloe" data-size="large" data-count="none">Tweet</a>
                    </td>
                </tr>
            </table>
        </div>
    </div>

</body>

Javascript: Javascript:

function getFacebook() {
window.fbAsyncInit = function () {
    FB.init({
        appId: 'xxx',
        xfbml: true,
        version: 'v2.3'
    });
};

(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/nl_NL/sdk.js";
    fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));};

XML config: XML配置:

<gap:plugin name="com.phonegap.plugins.facebookconnect" version="0.9.0">
    <param name="APP_ID" value="xxx" />
    <param name="APP_NAME" value="Mamyloe app" />
</gap:plugin>

            <access origin="*" />

        <feature name="Accelerometer">
            <param name="ios-package"     value="CDVAccelerometer" />
        </feature>
        <feature name="Geolocation">
            <param name="ios-package"     value="CDVLocation" />
        </feature>
        <feature name="Geolocation">
            <param name="android-package"   value="org.apache.cordova.geolocation.GeoBroker" />
        </feature>
        <feature name="Camera">
            <param name="android-package" value="org.apache.cordova.camera.CameraLauncher" />
        </feature>
        <feature name="Camera">
            <param name="ios-package" value="CDVCamera" />
        </feature>
        <feature name="File">
            <param name="android-package" value="org.apache.cordova.FileUtils" />
        </feature>
        <feature name="FileTransfer">
            <param name="android-package" value="org.apache.cordova.FileTransfer" />
        </feature>
        <feature name="File">
            <param name="ios-package" value="CDVFile" />
        </feature>
        <feature name="FileTransfer">
            <param name="ios-package" value="CDVFileTransfer" />
        </feature>
        <feature name="org.apache.cordova.facebook.Connect">
            <param name="android-package value="org.apache.cordova.facebook.ConnectPlugin" />
        </feature>



        <feature name="http://api.phonegap.com/1.0/camera" />
        <feature name="http://api.phonegap.com/1.0/file" />
        <feature name="http://api.phonegap.com/1.0/geolocation"/>
        <feature name="http://api.phonegap.com/1.0/network" />

@Tim, @Tim,

I do not see your CSS. 我看不到您的CSS。 There is clearly an class="fb-like" in your HTML. HTML中显然有一个class="fb-like" It is quite likely you need to add that URL for the image to your access class. 您很有可能需要将图像的URL添加到访问类中。 Either that or change the CSS so you can keep the image locally. 要么更改CSS,要么将图像保留在本地。

However, I could be wrong, as I cannot see the CSS. 但是,我可能错了,因为看不到CSS。

Jesse 杰西

You have in your code: 您的代码中包含:

<div class="fb-like" data-href="http://www.mamyloe.nl/uitjes/{{uitje.id}}" data-layout="button_count" data-action="like" data-show-faces="false" data-share="false"></div>

The first "class" in your <div> says "fb-like" . 您的<div>的第一个“类”表示“ fb-like” Somewhere in your CSS it has to have a .fb-like If you do not, this does not make sense. CSS中的某个位置必须具有类似.fb的样式。如果没有,则没有意义。

On the image url() , see: CSS background-image Property 在图像url() ,请参阅: CSS background-image属性

Jesse 杰西

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

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