・tiapp.xml
<!--modules/--> <modules> <!-- Add the appropriate line(s) to your modules section --> <module platform="android">facebook</module> <module platform="iphone">facebook</module> </modules>
・alloy.coffee
※JavaScriptを使う人はalloy.jsをいじる。
Alloy.Globals.Facebook = require('facebook')
・index.jade
→これで実際のボタンが配置される。
Alloy Window.container LoginButton#fbButton(ns="Alloy.Globals.Facebook")
〜(ns="Ti.Facebook") のもあるので注意!
おそらく古いモジュール?
・index.coffeee
fb = Alloy.Globals.Facebook fb.appid = "265040643542216" fb.permissions = ['publish_stream', 'create_event', 'email'] $.fbButton.style = fb.BUTTON_STYLE_WIDE fb.addEventListener('login', (e)-> if e.success fb.requestWithGraphPath('me', {}, 'GET', (e)-> if e.success # alert(e.result) response = JSON.parse(e.result) email = response.email name = response.name gender = response.gender alert(name+' '+email+' '+gender) alert('Logged in Successfully') else if (e.error) alert(e.error) else alert('Unknown response') ) )
で配置とクリック時の処理。
※addEventListener('click', (e)->ではないので注意
ボタンを押した時の処理は他に書く。
参考URL: http://stackoverflow.com/questions/12605031/titanium-facebook-authorize-an-error-occurred