【问题标题】:Titanium Facebook Dialog does not appearTitanium Facebook 对话框不出现
【发布时间】:2013-08-16 18:33:18
【问题描述】:

我正在开发一个“在 facebook 上分享”按钮。

但是有一个问题,facebook对话框没有提示给用户。

我试过钛提供的样品:

function facebook(){

    var fb = require('facebook');

    var data = {
        link : "http://www.appcelerator.com",
        name : "Appcelerator Titanium Mobile",
        message : "Checkout this cool open source project for creating apps",
        caption : "Appcelerator Titanium Mobile",
        picture : "http://developer.appcelerator.com/assets/img/DEV_titmobile_image.png",
        description : "You've got the ideas, now you've got the power."
    };

    fb.dialog("feed", data, function(e) {

            var toast = Ti.UI.createNotification({
            message:"Default",
            duration: Ti.UI.NOTIFICATION_DURATION_LONG
        });

            if(e.success && e.result) 
                toast.message = "Success! New Post ID: " + e.result;
            else {
                if(e.error) 
                        toast.message = e.error;
                else 
                    toast.message = "User canceled dialog.";
            }
        toast.show();
    });
}

函数调用正确,但什么也没出现。

有人知道为什么吗?也许权限?但我已经读到对话框不需要权限!

谢谢大家

【问题讨论】:

    标签: titanium titanium-mobile titanium-modules


    【解决方案1】:

    试试这个:

    var fb = require('facebook');
    fb.appid = FACEBOOK_APP_ID;
    fb.permissions = ['publish_stream']; // Permissions your app needs
    fb.forceDialogAuth = true;
    fb.addEventListener('login', function(e) {
        if (e.success) {
            alert('Logged In');
        } else if (e.error) {
            alert(e.error);
        } else if (e.cancelled) {
            alert("Canceled");
        }
    });
    fb.authorize();
    

    【讨论】:

      【解决方案2】:

      我自己解决了! 即使 Facebook Dialog 不需要 Auth(),它也需要带有 AppID 的 init。

      var fb = require('facebook');
      fb.appid = your_app_id_number;
      

      这个效果很好。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-02-12
        • 1970-01-01
        相关资源
        最近更新 更多