2012-03-23 9 views
0

チタニウムモバイルに慣れてきて、今ではiOSアプリを開発しています。チタニウムモバイルのFacebookカスタムログイン

カスタムログインボタンを作成したいと思います。 私はウェブ上のいくつかの指示に従ったが、それでも動作していない。 コードは次のとおりです。

var win = Ti.UI.currentWindow; 
Titanium.Facebook.appid = "APP ID"; 
Titanium.Facebook.permissions = ['permissions here']; 

var login = Ti.UI.createButton({ 
    backgroundImage:'facebooklogin.png', 
    width:250, 
    height40: 
}); 

win.add(login); 

login.addEventListener('click', function(e) { 
    Titanium.Facebook.authorize(); 
}); 

Titanium.Facebook.addEventListener('login', function(e) { 
     if (e.success) { 
      Titanium.Facebook.requestWithGraphPath('me', {}, 'GET', function(e) { 
       if (e.success) { 
        var data= JSON.parse(e.result); 
        Ti.API.info("Name:"+data.name); 
        Ti.API.info("email:"+data.email); 
        Ti.API.info("facebook Id:"+data.id); 
       } else if (e.error) { 
        alert(e.error); 
       } else { 
        alert('Unknown response.'); 
       } 
      }); 
     }else{ 
      if(e.error){ 
       alert(e.error); 
      }else{ 
       alert("Unkown error while trying to login to facebook."); 
      } 
     } 
    }); 
} 

誰でも私に解決策を示しますか?

ありがとうございました。

+0

エラーは何ですか? – DannyM

+0

ああ、私はそれについて書くのを忘れてしまった。 ボタンをクリックすると、何も起こりません。私はFacebookのログインについてのモーダルウインドウが来ると思ったが、.... – user1258134

答えて

0

あなたが既に認可されている場合、Ti.Facebook.authorizeメソッドは何もしません。デバイスからアプリデータを消去してからやり直してみてください。

関連する問題