问题
I'm trying to create a login with Facebook using the Facebook modules that comes in Titanium framework.
When I do a button click on the iphone emulator I get the login screen to Facebook. But when I install on the device I don't get the login screen - as if doesn't do anything (no errors). I've placed an alert to see that that place of code is called when the button clicks - it does.
here's my code on button click:
Alloy.Globals.Facebook.permissions = ['public_profile', 'user_friends', 'email', 'user_about_me', 'user_events', 'user_hometown',
'user_likes', 'user_photos', 'user_posts', 'user_videos', 'user_tagged_places', 'user_work_history'];
Alloy.Globals.Facebook.addEventListener('login', function(e) {
// do some stuff
}
Alloy.Globals.Facebook.initialize();
Alloy.Globals.Facebook.authorize();
Again - on emulator works well, on device not showing facebook login.
回答1:
On iOS you need to have the following in tiapp.xml:
<!-- Enable App Transport Security for Facebook -->
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>facebook.com</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSExceptionRequiresForwardSecrecy</key>
<false/>
</dict>
<key>fbcdn.net</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSExceptionRequiresForwardSecrecy</key>
<false/>
</dict>
<key>akamaihd.net</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSExceptionRequiresForwardSecrecy</key>
<false/>
</dict>
</dict>
And on Android:
<application>
<activity android:label="@string/app_name"
android:name="com.facebook.LoginActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar"/>
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/>
</application>
来源:https://stackoverflow.com/questions/36071120/titanium-facebook-login-doesnt-show-on-device