简体   繁体   English

Titanium Facebook模块无法在iOS 7上完成登录

[英]Titanium Facebook module not completing login on iOS 7

I've run into a weird issue using Titanium 3.2.0.GA and the Facebook module. 使用Titanium 3.2.0.GA和Facebook模块遇到了一个奇怪的问题。 When I try calling fb.authorize(); 当我尝试调用fb.authorize();时 and if I'm logged into Facebook through iOS 7, the dialog pops up asking if I would like to allow it to blah blah blah. 如果我通过iOS 7登录到Facebook,则会弹出对话框,询问我是否要允许它等等。 But once I tap "Allow", it triggers the login event with code -1, and is unsuccessful. 但是,一旦我点击“允许”,它将触发代码为-1的登录事件,但未成功。 However, if I'm not logged into Facebook through iOS 7, and login to Facebook through Safari after calling fb.authorize();, everything works as expected and the login event is triggered successfully. 但是,如果我没有通过iOS 7登录到Facebook,而是在调用fb.authorize();之后通过Safari登录到Facebook,则一切正常,并且成功触发了登录事件。

var fb = require('facebook');
fb.appid = ****;
fb.permissions = ['email'];
fb.forceDialogAuth = false;

fb.addEventListener("login", function(e) {
    if (fb.success && fb.accessToken != null) {
        console.log(fb.accessToken);
    }
});

And like I said above, when the Facebook button is pressed I just call fb.authorize(); 就像我上面说的那样,当按下Facebook按钮时,我只需调用fb.authorize(); .

Is anyone else having issues like this on iOS 7 using Titanium? 使用Titanium在iOS 7上是否还有其他人遇到这样的问题?

Looks like I fixed it. 看起来像我修复了它。 On my Facebook app, I had to add an iOS app and turn the "Single Sign On" on. 在我的Facebook应用程序上,我必须添加一个iOS应用程序并打开“单一登录”。 Facebook was having issues last night and wouldn't let me make changes to my app but I just tried it today and it works now. Facebook昨晚遇到了问题,不允许我对我的应用进行更改,但我今天才尝试过,现在就可以使用。 I think this might be something new for iOS 7, but I'm not sure. 我认为这可能是iOS 7的新功能,但我不确定。 However, turning Single Sign On to On worked for me. 但是,将Single Sign On设置为On对我有用。

Just declare All bellow variables in calling function only not globally other wise each time it will call fb.authorize(). 仅在每次调用fb.authorize()时才在调用函数中声明所有波纹管变量,而不会全局其他方式声明。

ie

var fb = null;
function facbooksharing(sharingData){
      if(fb == null){

        fb = require('facebook');
        fb.appid = "******";
        fb.permissions = ['publish_stream', 'read_stream','publish_actions'];
        fb.forceDialogAuth = true; `enter code here`
    }
        if(fb.loggedIn==true)
     {
        fb.dialog("feed", sharingData, showRequestResult);
     }else{

       fb.authorize();
     }
      function showRequestResult(e) 
    {

        if (e.success)
         {
           if (e.result)
            {
               Ti.API.info("Data Shared between your friend successfully.");
            }
        }
    }

      fb.addEventListener("login", function(e) {
      if (fb.success && fb.accessToken != null) {
            console.log(fb.accessToken);
      }
});

}

Let me know is this resolve your problem or not. 让我知道这是否解决了您的问题。

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

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