Phonegap + Facebook

时间:2015-05-18 12:44:35

标签: javascript android ios facebook cordova

我想在我的混合应用中使用Facebook javascript SDK插件集成Facebook“like”按钮。 “like”按钮在浏览器上完美运行,但是当我使用Phonegap 3.7.0构建项目并在Android(5.0)iOS(8.1.2)上运行时,“按钮”按钮不显示

我试过这个:https://github.com/Wizcorp/phonegap-facebook-plugin/blob/master/platforms/pg-build/README.md但仍然没有按钮...

我希望有人可以帮助我,

提前致谢!

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:

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配置:                                                                              

<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" />

2 个答案:

答案 0 :(得分:0)

@Tim,

我没看到你的CSS。您的HTML中显然有class="fb-like"。您很可能需要将图像的URL添加到访问类。要么是这样,要么改变CSS,以便你可以在本地保存图像。

然而,我可能错了,因为我看不到CSS。

杰西

答案 1 :(得分:0)

您的代码中包含:

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

第一个&#34;班级&#34;在<div>中说&#34; fb-like&#34; 。在CSS的某个地方,它必须具有.fb-like如果你不这样做,这没有意义。

在图片url()上,请参阅:CSS background-image Property

杰西